home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 60914 / 60914.xpi / chrome / content / personas.js < prev    next >
Text File  |  2010-01-22  |  161KB  |  4,049 lines

  1. ∩╗┐        
  2.     var PersonasWindow={
  3.         
  4.         filename:null,
  5.         actualfilename:null,
  6.         updateModeOn:false,    
  7.         personaImagePreName:"personasrotator/",
  8.         databaseResourceSiteName:"chrome://personasrotator/content/personasrotator/",
  9.         openTabURI:"chrome://personasrotator/content/wr.html",
  10.         paths:[],
  11.         arrayinc:0,
  12.         additemsstate:false,
  13.         editstate:false,
  14.         copystate:false,
  15.         cutstate:false,
  16.         deletestate:false,
  17.         returndiv:"",
  18.         warningTimeoutId:null,
  19.         warningStillShowing:false,
  20.         returnscrollx:null,
  21.         returnscrolly:null,
  22.         personasarray:[],
  23.         fillspacestate:false,
  24.         fillspaceadditemsettimeoutid:null,
  25.         fillspacebackuparray:[],
  26.         copypasteprocessingstate:false,
  27.         cutpasteprocessingstate:false,
  28.         STRINGS:null,
  29.         
  30.         handleWindowLoad:function (event) {
  31.  
  32.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  33.  
  34.             var container=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:library"));
  35.             var genericpersonasseqenumurator=container.GetElements();
  36.             var namePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  37.             
  38.             while (genericpersonasseqenumurator.hasMoreElements()) {
  39.         
  40.                 var collection=genericpersonasseqenumurator.getNext();
  41.                 
  42.                 var nametarget=ds.GetTarget(collection,namePredicate,true);
  43.                 
  44.                 if (nametarget) {
  45.                     
  46.                     var name = nametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  47.  
  48.                 }
  49.                 
  50.                 var newbutton=document.createElement("label");
  51.  
  52.                 newbutton.setAttribute("value",name);
  53.                 
  54.                 newbutton.setAttribute("crop","end");
  55.                 
  56.                 newbutton.setAttribute("id",encodeURI(name)+"button");
  57.                 
  58.                 newbutton.setAttribute("onclick","PersonasWindow.clickhandle(event);");
  59.                 
  60.                 newbutton.setAttribute("context","button-popup");
  61.                 
  62.                 newbutton.setAttribute("class","collection-button");
  63.                 
  64.                 document.getElementById("collectionscolumn").appendChild(newbutton);
  65.  
  66.                 var newhtmldiv=document.createElementNS("http://www.w3.org/1999/xhtml","html:div");
  67.  
  68.                 newhtmldiv.setAttribute("id",encodeURI(name)+"htmldiv");
  69.                 
  70.                 newhtmldiv.setAttribute("class","inactive htmldiv");
  71.                 
  72.                 var relatedcollection=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+(PersonasWindow.createEncodedName(name))+"backs"));
  73.                 
  74.                 var collectionsseqenumurator=relatedcollection.GetElements();
  75.                 
  76.                 var totalpersonasnumber=0;
  77.                 
  78.                 while (collectionsseqenumurator.hasMoreElements()) {
  79.                 
  80.                     collectionsseqenumurator.getNext();
  81.                     totalpersonasnumber++;
  82.                 
  83.                 }
  84.                 
  85.                 if((totalpersonasnumber%3)==0) newhtmldiv.style.height=((totalpersonasnumber/3)*155)+"px";
  86.                 if((totalpersonasnumber%3)==1) newhtmldiv.style.height=(Math.round((totalpersonasnumber/3)+0.33)*155)+"px";
  87.                 if((totalpersonasnumber%3)==2) newhtmldiv.style.height=(Math.round((totalpersonasnumber/3))*155)+"px";
  88.                 
  89.                 document.getElementById("gallerystack").appendChild(newhtmldiv);
  90.                 
  91.             }
  92.             
  93.             /*
  94.             
  95.             var cfgretrieverdf = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
  96.             cfgretrieverdf.append("extensions");
  97.             cfgretrieverdf.append("{6e73f6b7-b9ab-44b8-b744-6393e3c2e351}");
  98.             cfgretrieverdf.append("chrome");
  99.             cfgretrieverdf.append("content");
  100.             cfgretrieverdf.append("retrieve");
  101.             cfgretrieverdf.append("retrieve.rdf");
  102.             
  103.             var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
  104.             
  105.             var dsx=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(ioService.newFileURI(cfgretrieverdf).spec);    
  106.  
  107.             var retrievedscontainer=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(dsx,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:retrieveds"));
  108.             
  109.             var retrievedsseqenumurator=retrievedscontainer.GetElements();
  110.             
  111.             var retrievedimagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  112.             var retrievedimagelocationPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#location");
  113.             var retrievedimagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  114.             var retrievedimagesiteuriPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#siteuri");
  115.             var i=0;
  116.             while (retrievedsseqenumurator.hasMoreElements()) {
  117.                 
  118.                 var retrievedimageresource=retrievedsseqenumurator.getNext();
  119.                 
  120.                 var retrievedimagenametarget=dsx.GetTarget(retrievedimageresource,retrievedimagenamePredicate,true);
  121.                 
  122.                 if (retrievedimagenametarget) {
  123.                     
  124.                     var retrievedimagename = retrievedimagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  125.  
  126.                 }                
  127.                 
  128.                 var retrievedimagelocationtarget=dsx.GetTarget(retrievedimageresource,retrievedimagelocationPredicate,true);
  129.                 
  130.                 if (retrievedimagelocationtarget) {
  131.                     
  132.                     var retrievedimagelocation = retrievedimagelocationtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  133.  
  134.                 }    
  135.                 
  136.                 var retrievedimagedescriptiontarget=dsx.GetTarget(retrievedimageresource,retrievedimagedescriptionPredicate,true);
  137.                 
  138.                 if (retrievedimagedescriptiontarget) {
  139.                     
  140.                     var retrievedimagedescription = retrievedimagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  141.  
  142.                 }
  143.                 
  144.                 var retrievedimagesiteuritarget=dsx.GetTarget(retrievedimageresource,retrievedimagesiteuriPredicate,true);
  145.                 
  146.                 if (retrievedimagesiteuritarget) {
  147.                     
  148.                     var retrievedimagesiteuri = retrievedimagesiteuritarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  149.  
  150.                 }    
  151.  
  152.                 document.getElementById("newshtmldiv").getElementsByTagName("image")[i].src="chrome://personasrotator/content/retrieve/"+retrievedimagelocation;
  153.                 document.getElementById("newshtmldiv").getElementsByTagName("image")[i].setAttribute("tooltiptext",retrievedimagename+" - Double click on it to visit web page");
  154.                 document.getElementById("newshtmldiv").getElementsByTagName("image")[i].nextSibling.nextSibling.firstChild.nodeValue=retrievedimagename;
  155.                 document.getElementById("newshtmldiv").getElementsByTagName("image")[i].nextSibling.nextSibling.siteuri=retrievedimagesiteuri;
  156.                 document.getElementById("newshtmldiv").getElementsByTagName("image")[i].siteuri=retrievedimagesiteuri;
  157.  
  158.                 i++;
  159.                 
  160.             }
  161.             
  162.             */
  163.             
  164.             PersonasWindow.STRINGS = document.getElementById("personas-strings");
  165.             
  166.         },
  167.         
  168.         resetContextMenuPopup:function(event){
  169.                         
  170.                 if(document.getElementById("image-open").hasAttribute("disabled")) document.getElementById("image-open").removeAttribute("disabled");
  171.                 if(document.getElementById("image-open").hidden) document.getElementById("image-open").setAttribute("hidden","false");
  172.                 
  173.                 if(document.getElementById("image-edit").hasAttribute("disabled")) document.getElementById("image-edit").removeAttribute("disabled");
  174.                 if(document.getElementById("image-edit").hidden) document.getElementById("image-edit").setAttribute("hidden","false");
  175.                     
  176.                 if(document.getElementById("image-edit-persona").hasAttribute("disabled")) document.getElementById("image-edit-persona").removeAttribute("disabled");
  177.                 if(document.getElementById("image-edit-persona").hidden) document.getElementById("image-edit-persona").setAttribute("hidden","false");
  178.                 
  179.                 if(document.getElementById("image-copy").hasAttribute("disabled")) document.getElementById("image-copy").removeAttribute("disabled");
  180.                 if(document.getElementById("image-copy").hidden) document.getElementById("image-copy").setAttribute("hidden","false");
  181.                             
  182.                 if(document.getElementById("image-cut").hasAttribute("disabled")) document.getElementById("image-cut").removeAttribute("disabled");
  183.                 if(document.getElementById("image-cut").hidden) document.getElementById("image-cut").setAttribute("hidden","false");
  184.                                     
  185.                 if(document.getElementById("image-paste").hasAttribute("disabled")) document.getElementById("image-paste").removeAttribute("disabled");
  186.                 if(document.getElementById("image-paste").hidden) document.getElementById("image-paste").setAttribute("hidden","false");
  187.                                     
  188.                 if(document.getElementById("image-upload").hasAttribute("disabled")) document.getElementById("image-upload").removeAttribute("disabled");
  189.                 if(document.getElementById("image-upload").hidden) document.getElementById("image-upload").setAttribute("hidden","false");
  190.                                         
  191.                 if(document.getElementById("image-delete").hasAttribute("disabled")) document.getElementById("image-delete").removeAttribute("disabled");
  192.                 if(document.getElementById("image-delete").hidden) document.getElementById("image-delete").setAttribute("hidden","false");
  193.  
  194.         },
  195.         
  196.         disableContextMenuItems:function(passedarray){
  197.  
  198.             for (var i=0;i<passedarray.length;i++){
  199.                     
  200.                 if(passedarray[i]=="image-open") document.getElementById("image-open").setAttribute("disabled","true");
  201.                 
  202.                 else if (passedarray[i]=="image-edit") document.getElementById("image-edit").setAttribute("disabled","true");
  203.                 
  204.                 else if (passedarray[i]=="image-edit-persona") document.getElementById("image-edit-persona").setAttribute("disabled","true");
  205.                 
  206.                 else if (passedarray[i]=="image-copy") document.getElementById("image-copy").setAttribute("disabled","true");
  207.                 
  208.                 else if (passedarray[i]=="image-cut") document.getElementById("image-cut").setAttribute("disabled","true");
  209.                 
  210.                 else if (passedarray[i]=="image-paste") document.getElementById("image-paste").setAttribute("disabled","true");
  211.                 
  212.                 else if (passedarray[i]=="image-upload") document.getElementById("image-upload").setAttribute("disabled","true");
  213.                     
  214.                 else if (passedarray[i]=="image-delete") document.getElementById("image-delete").setAttribute("disabled","true");
  215.                     
  216.             }
  217.         
  218.         },
  219.         
  220.         hideContextMenuItems:function(passedarray){
  221.         
  222.             for (var i=0;i<passedarray.length;i++){
  223.                     
  224.                 if(passedarray[i]=="image-open") document.getElementById("image-open").setAttribute("hidden","true");
  225.                 
  226.                 else if (passedarray[i]=="image-edit") document.getElementById("image-edit").setAttribute("hidden","true");
  227.                 
  228.                 else if (passedarray[i]=="image-edit-persona") document.getElementById("image-edit-persona").setAttribute("hidden","true");
  229.                 
  230.                 else if (passedarray[i]=="image-copy") document.getElementById("image-copy").setAttribute("hidden","true");
  231.                 
  232.                 else if (passedarray[i]=="image-cut") document.getElementById("image-cut").setAttribute("hidden","true");
  233.                 
  234.                 else if (passedarray[i]=="image-paste") document.getElementById("image-paste").setAttribute("hidden","true");
  235.                 
  236.                 else if (passedarray[i]=="image-upload") document.getElementById("image-upload").setAttribute("hidden","true");
  237.                     
  238.                 else if (passedarray[i]=="image-delete") document.getElementById("image-delete").setAttribute("hidden","true");
  239.                     
  240.             }
  241.         
  242.         },
  243.         
  244.         contextMenuPopupHandle:function(event){
  245.             
  246.             var nsIPopupBoxObject = Components.interfaces.nsIPopupBoxObject;
  247.  
  248.             event.target.popupBoxObject.setConsumeRollupEvent(nsIPopupBoxObject.ROLLUP_NO_CONSUME);
  249.             
  250.             
  251.             if(PersonasWindow.editstate==true) {event.preventDefault(); return;} 
  252.         
  253.             if(document.getElementsByClassName("active")[0]!=undefined) {     
  254.                 
  255.                 if(PersonasWindow.hasClass(document.getElementsByClassName("active")[0],"donatehtmldiv")) {event.preventDefault();return;}
  256.             
  257.             }
  258.             
  259.             PersonasWindow.resetContextMenuPopup();
  260.             
  261.             if(PersonasWindow.hasClass(document.popupNode,"personasrotatorimage")||PersonasWindow.hasClass(document.popupNode,"serdo")){
  262.                 
  263.                 if(document.getElementsByClassName("active")[0]!=undefined) { 
  264.                     
  265.                     if(document.getElementsByClassName("active")[0].getAttribute("id")=="newshtmldiv"){
  266.                     
  267.                         var disablearray=["image-edit","image-edit-persona","image-copy","image-cut","image-delete","image-paste","image-upload"];
  268.                         
  269.                         PersonasWindow.disableContextMenuItems(disablearray);
  270.                         
  271.                         return;
  272.                 
  273.                     }
  274.                 
  275.                 }
  276.                 
  277.                 var hidearray=["image-paste"];
  278.  
  279.                 PersonasWindow.hideContextMenuItems(hidearray);
  280.         
  281.             }    
  282.             
  283.             else if(PersonasWindow.hasClass(document.popupNode,"edithtmldiv")||PersonasWindow.hasClass(document.popupNode,"active")||document.popupNode.getAttribute("id")=="personapools"||document.popupNode.getAttribute("id")=="gallerystack"||document.popupNode.getAttribute("class")=="imagewrapperdiv"){
  284.  
  285.                 var disablearray=["image-open","image-edit","image-edit-persona","image-copy","image-cut","image-delete","image-upload"];
  286.                     
  287.                 if (PersonasWindow.copystate==true||PersonasWindow.cutstate==true){
  288.             
  289.                     if(PersonasWindow.hasClass(PersonaWindowSelectManager.highlighteds[0].parentNode.parentNode,"active")) disablearray.push("image-paste");
  290.                 
  291.                 }        
  292.             
  293.                 if(PersonasWindow.copystate==false && PersonasWindow.cutstate==false) {
  294.                 
  295.                     disablearray.push("image-paste");
  296.                     
  297.                 }
  298.                 
  299.                 PersonasWindow.disableContextMenuItems(disablearray);
  300.             
  301.             }
  302.  
  303.         },
  304.         
  305.         hasClass:function(domnode,passedclass){
  306.         
  307.             var searchpattern=new RegExp("( |^)"+passedclass+"($| )");
  308.             
  309.             if (searchpattern.test(domnode.className)) return true;
  310.             return false;
  311.             
  312.         },
  313.  
  314.         getlibraryfileURI : function () {
  315.  
  316.             
  317.             var file = Components.classes["@mozilla.org/file/directory_service;1"]
  318.                                  .getService(Components.interfaces.nsIProperties)
  319.                                  .get("ProfD", Components.interfaces.nsIFile);
  320.         
  321.             file.append("personasrotator");
  322.             file.append("library.rdf");
  323.             
  324.             var ios = Components.classes["@mozilla.org/network/io-service;1"]
  325.                                 .getService(Components.interfaces.nsIIOService);
  326.             var URL = ios.newFileURI(file);
  327.  
  328.             return URL.spec;
  329.  
  330.         },
  331.         
  332.         handleFileSelection:function(){
  333.                 
  334.             const nsIFilePicker = Components.interfaces.nsIFilePicker;
  335.  
  336.             var filepicker = Components.classes["@mozilla.org/filepicker;1"]
  337.                            .createInstance(nsIFilePicker);
  338.                            
  339.             filepicker.init(window, PersonasWindow.STRINGS.getString("choosePersonas") , nsIFilePicker.modeOpen);
  340.             
  341.             filepicker.appendFilters(nsIFilePicker.filterImages );
  342.  
  343.             var returnvalue = filepicker.show();
  344.             
  345.             if (returnvalue == nsIFilePicker.returnOK || returnvalue == nsIFilePicker.returnReplace) {
  346.             
  347.                 PersonasWindow.processFilesForAddition(filepicker.file);
  348.                 
  349.             }
  350.  
  351.         },
  352.             
  353.         processFilesForAddition:function(file){
  354.             
  355.             var itemsleft=PersonasWindow.paths.length-PersonasWindow.arrayinc;
  356.             
  357.             PersonasWindow.copyTheImage(file);
  358.  
  359.             PersonasWindow.saveTheThumb(PersonasWindow.filename);
  360.             
  361.             PersonasWindow.createEmptyRdf(PersonasWindow.filename);
  362.             
  363.             PersonasWindow.savePersonaPositionGlobally(PersonasWindow.filename);
  364.             
  365.         },
  366.             
  367.         copyTheImage:function(file) {
  368.             
  369.             var filechosen = file; 
  370.         
  371.             var leafName=filechosen.leafName;
  372.  
  373.             var createdCompositeFileName=decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,""))+"/"+"Personas"+"/"+leafName; 
  374.             
  375.             var filename=PersonasWindow.checkNameCollison(createdCompositeFileName);
  376.  
  377.             var filem=PersonasWindow.getAppropriateCollectionDirectoryFromFileName(filename);
  378.  
  379.             filechosen.copyTo(filem,PersonasWindow.getTheLeafNameFromFileNameString(filename));
  380.             
  381.             PersonasWindow.filename=filename;
  382.             
  383.             PersonasWindow.actualfilename=leafName;
  384.  
  385.         },
  386.             
  387.         checkNameCollison: function (filename) {
  388.  
  389.             var file =PersonasWindow.getChromeFile(filename);
  390.             
  391.             var inc=1;
  392.             
  393.             var changedname="";
  394.             
  395.             while (file.exists()) {
  396.                         
  397.                 inc++;
  398.                     
  399.                 var namesplitarray=filename.split("/");
  400.  
  401.                 for (var i=0;i<namesplitarray.length;i++) {
  402.                 
  403.                     if(i==namesplitarray.length-1) {
  404.  
  405.                         var array=namesplitarray[i].split(".");
  406.  
  407.                         var imageextension=array[array.length-1];
  408.  
  409.                         var newLeafName=namesplitarray[i].replace("."+imageextension,"("+inc+")"+"."+imageextension);
  410.                     
  411.                         changedname+=newLeafName;
  412.                         
  413.                         break;
  414.  
  415.                     }
  416.                     
  417.                     changedname+=namesplitarray[i]+"/";
  418.  
  419.                 }
  420.             
  421.                 filename=changedname;
  422.                 
  423.                 file =PersonasWindow.getChromeFile(filename);
  424.                 
  425.                 changedname="";
  426.                 
  427.             }
  428.         
  429.             return filename;
  430.  
  431.         },
  432.  
  433.         getChromeFile:function(filename) {
  434.         
  435.             if (filename==undefined || filename==null)    return;
  436.             
  437.             var namesplitarray=filename.split("/");
  438.             
  439.             var file = Components.classes["@mozilla.org/file/directory_service;1"]
  440.                                  .getService(Components.interfaces.nsIProperties)
  441.                                  .get("ProfD", Components.interfaces.nsIFile);
  442.  
  443.             file.append("personasrotator");
  444.             
  445.             for (var i=0;i<namesplitarray.length;i++) {
  446.             
  447.                 file.append(namesplitarray[i]);
  448.             
  449.             }
  450.             
  451.             return file;
  452.  
  453.         },
  454.  
  455.         getAppropriateCollectionDirectoryFromFileName:function(filename) {
  456.         
  457.             var namesplitarray=filename.split("/");
  458.             
  459.             var file = Components.classes["@mozilla.org/file/directory_service;1"]
  460.                                  .getService(Components.interfaces.nsIProperties)
  461.                                  .get("ProfD", Components.interfaces.nsIFile);
  462.  
  463.             file.append("personasrotator");
  464.             
  465.             for (var i=0;i<namesplitarray.length;i++) {
  466.                 
  467.                 if(i==2) break;
  468.                 file.append(namesplitarray[i]);
  469.             
  470.             }
  471.  
  472.             return file;
  473.         
  474.         },
  475.  
  476.         createTheThumbandSave:function(ctx,img,canvas,filey){
  477.  
  478.             ctx.clearRect(0,0,138,109);
  479.                                 
  480.             var array=img.src.split(".");
  481.  
  482.             var imageextension=array[array.length-1];
  483.             
  484.             if(imageextension!="png" && imageextension!="gif") {
  485.                 
  486.                 ctx.fillStyle="#f5f5f5";
  487.                 ctx.fillRect(0, 0, 138, 109);
  488.                 
  489.             }
  490.             
  491.             var imagewidth=img.naturalWidth;
  492.             var imageheight=img.naturalHeight;
  493.             var widthratio=imagewidth/138.0;
  494.             var heightratio=imageheight/109.0;
  495.             
  496.             var correctratio=(widthratio>heightratio) ? widthratio :heightratio;
  497.             
  498.             var heightforresize=imageheight/correctratio;
  499.             var widthforresize=imagewidth/correctratio;
  500.             
  501.             var verticalposition=(109-heightforresize)/2;
  502.             var horiziontalposition=(138-widthforresize)/2;
  503.             
  504.             ctx.drawImage(img,horiziontalposition,verticalposition,widthforresize,heightforresize);
  505.             
  506.             PersonasWindow.saveCanvas(canvas,filey.path);
  507.         
  508.         },
  509.         
  510.         saveTheThumb:function (filename) {
  511.             
  512.             var inc=0;
  513.             
  514.             var filey = PersonasWindow.getThumbFile(filename);        
  515.         
  516.             var img = new Image();
  517.             
  518.             var canvas=document.getElementById("canvas");
  519.  
  520.             var ctx = canvas.getContext('2d');
  521.  
  522.             img.onload = function() {
  523.             
  524.                 window.setTimeout(function(){
  525.                             
  526.                     try{
  527.  
  528.                         PersonasWindow.createTheThumbandSave(ctx,img,canvas,filey);
  529.                     
  530.                     }
  531.                     
  532.                     catch(err){
  533.  
  534.                         looper(inc);
  535.  
  536.                     }
  537.                             
  538.                 },1);
  539.                 
  540.             }
  541.  
  542.             function looper(inc) {
  543.             
  544.                 window.setTimeout(function(){
  545.                             
  546.                     try{
  547.                     
  548.                         PersonasWindow.createTheThumbandSave(ctx,img,canvas,filey);
  549.                     
  550.                     }
  551.                     
  552.                     catch(err){
  553.  
  554.                         looper(inc++);
  555.  
  556.                     }
  557.             
  558.                 },(inc+1)*50);    
  559.             
  560.             }
  561.             
  562.             img.src = PersonasWindow.assignFileURIToImage(filename);
  563.         
  564.         },
  565.                 
  566.         getThumbFile:function(filename) {
  567.             
  568.             var createdThumbImageName=PersonasWindow.createThumbImageName(filename);
  569.  
  570.             return PersonasWindow.getChromeFile(createdThumbImageName);
  571.  
  572.         },
  573.  
  574.         createThumbImageName:function(filename){
  575.         
  576.             var namesplitarray=filename.split("/");
  577.         
  578.             var createdThumbImageName="";
  579.             
  580.             for (var i=0;i<namesplitarray.length;i++) {
  581.             
  582.                 if(i==namesplitarray.length-1) {createdThumbImageName+="Thumb_"+namesplitarray[i];break;}
  583.                 if(i!=1) createdThumbImageName+=namesplitarray[i]+"/";
  584.                 else  createdThumbImageName+="Thumbs/";
  585.                 
  586.             }
  587.  
  588.             return createdThumbImageName;
  589.             
  590.         },
  591.         
  592.         saveCanvas:function (canvas,destFile) {
  593.             
  594.             var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  595.             
  596.             file.initWithPath(destFile);
  597.             
  598.             var io=Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
  599.  
  600.             var source=io.newURI(canvas.toDataURL(PersonasWindow.createMIMEType(destFile),""),"UTF8",null);
  601.             
  602.             var target=io.newFileURI(file)
  603.             
  604.             var persist=Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
  605.  
  606.             persist.persistFlags=Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
  607.             
  608.             persist.persistFlags |=Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
  609.  
  610.             persist.progressListener={
  611.  
  612.                 onStateChange:function(aWebProgress,aRequest,aFlag,aStatus){
  613.                     
  614.                     if(aFlag==327696){
  615.  
  616.                         PersonasWindow.createOtherImageRequirements(PersonasWindow.filename);
  617.  
  618.                     }
  619.  
  620.                 }
  621.  
  622.             }
  623.           
  624.           persist.saveURI(source,null,null,null,null,file);
  625.               
  626.         },
  627.         
  628.         createMIMEType:function(destFile){
  629.         
  630.             if(destFile.search(/.png$/)!=-1) return "image/png";
  631.             if(destFile.search(/.jpg$/)!=-1) return "image/jpeg";
  632.             if(destFile.search(/.jpeg$/)!=-1) return "image/jpeg";
  633.             if(destFile.search(/.svg$/)!=-1) return "image/svg+xml";
  634.             return "image/png";
  635.         
  636.         },
  637.         
  638.         createEmptyRdf:function(filename){
  639.             
  640.             var descriptionForImage="undefined";    
  641.             var nameForImage=PersonasWindow.actualfilename.replace(/\.\w+$/,"").replace(/&/g,"&");
  642.             var locationForImage=PersonasWindow.getTheLeafNameFromFileNameString(filename).replace(/&/g,"&");
  643.             var positionForImage="CENTER";
  644.             var defaultForImage="false";
  645.             var activecollectioname=filename.split("/")[0].replace(/&/g,"&");
  646.             var version="0.1";
  647.             var uploaded="false";
  648.             var siteURI="null".replace(/&/g,"&");
  649.             var source="local";
  650.             var screenRes=screen.width+"x"+screen.height;
  651.             var backgroundColor=PersonasWindow.retrieveDesktopBackgroundColor();
  652.             
  653.             var RDFstring='<?xml version="1.0"?>'
  654.             +'<RDF:RDF xmlns:personasrotator="urn:personasrotator#" xmlns:NC="http://home.netscape.com/NC-rdf#" xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'+'<RDF:Description RDF:about="'+(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename)).replace(/&/g,"&")+'" personasrotator:name="'+nameForImage+'" personasrotator:default="'+defaultForImage+'"   personasrotator:description="'+descriptionForImage+'" personasrotator:location="'+locationForImage+'" personasrotator:position="'+positionForImage+'" personasrotator:tags="'+activecollectioname+'" personasrotator:version="'+version+'" personasrotator:uploaded="'+uploaded+'" personasrotator:siteuri="'+siteURI+'" personasrotator:source="'+source+'" personasrotator:screenres="'+screenRes+'" personasrotator:backgroundcolor="'+backgroundColor+'" />'+'</RDF:RDF>';
  655.             var emptyRDFnsiFile=PersonasWindow.getChromeFile(PersonasWindow.createIndividualRDFFilename(filename));
  656.             
  657.             PersonasRotatorFileIO.write(emptyRDFnsiFile,RDFstring,"w","UTF-8");
  658.         
  659.         },
  660.         
  661.         getTheLeafNameFromFileNameString:function(filename) {
  662.         
  663.             var patharray=filename.split("/");
  664.             
  665.             var leafName=patharray[patharray.length-1];
  666.             
  667.             return leafName;
  668.  
  669.         },
  670.  
  671.         createIndividualRDFFilename:function(filename) {
  672.         
  673.             var array=filename.split(".");
  674.  
  675.             var imageextension=array[array.length-1];
  676.             
  677.             var rdffilename=filename+".rdf";
  678.             
  679.             var namesplitarray=rdffilename.split("/");
  680.         
  681.             var createdRDFName="";
  682.             
  683.             for (var i=0;i<namesplitarray.length;i++) {
  684.             
  685.                 if(i==namesplitarray.length-1) {createdRDFName+=namesplitarray[i];break;}
  686.                 if(i!=1) createdRDFName+=namesplitarray[i]+"/";
  687.                 else  createdRDFName+="RDFs/";
  688.                 
  689.             }
  690.         
  691.             return createdRDFName;
  692.             
  693.         },
  694.         
  695.         savePersonaPositionGlobally:function(filename) {
  696.         
  697.             PersonasWindow.savePersonaPositionForTheImage(filename);
  698.             PersonasWindow.addImageResourceNodeToLibraryDatabase(filename);
  699.             PersonasWindow.addImageResourceNodeToCollectionDatabase(filename);
  700.  
  701.         },
  702.         
  703.         savePersonaPositionForTheImage:function(filename) {
  704.             
  705.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createIndividualRDFFilename(filename)));
  706.             
  707.             var leafName=PersonasWindow.getTheLeafNameFromFileNameString(filename);
  708.  
  709.             var theImageNode = PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  710.             
  711.             var positionPredicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  712.         
  713.             var positiontarget=ds.GetTarget(theImageNode,positionPredicate,true);
  714.             
  715.             if (positiontarget!=null) var position= positiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  716.             else {return}
  717.             
  718.             var newposition="CENTER";
  719.             
  720.             var predicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  721.             var oldtarget=PersonasRotatorRDF.rdfService.GetLiteral(position);
  722.             var newtarget=PersonasRotatorRDF.rdfService.GetLiteral(newposition);
  723.             
  724.             ds.Change(theImageNode,predicate,oldtarget,newtarget);
  725.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  726.  
  727.         },    
  728.  
  729.         retrieveDesktopBackgroundColor:function(){
  730.  
  731.             return Components.classes["@mozilla.org/browser/shell-service;1"].getService(Components.interfaces.nsIShellService).desktopBackgroundColor;
  732.                                                  
  733.         },
  734.         
  735.         addImageResourceNodeToLibraryDatabase: function (filename) {
  736.  
  737.             var imagename = PersonasWindow.actualfilename.replace(/\.\w+$/,"");
  738.             var imagelocation = PersonasWindow.getTheLeafNameFromFileNameString(filename);
  739.             var imagedescription = "undefined";
  740.             var imageposition = "CENTER";
  741.             var activecollectioname=filename.split("/")[0];
  742.             var imageversion="0.1";
  743.             var imageuploaded="false";
  744.             var imagesiteURI="null".replace(/&/g,"&");
  745.             var imagesource="local";
  746.             var imagescreenRes=screen.width+"x"+screen.height;
  747.             var imagebackgroundColor=PersonasWindow.retrieveDesktopBackgroundColor();
  748.         
  749.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  750.  
  751.             var newnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  752.             
  753.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  754.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( "false" ),true);
  755.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  756.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  757.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  758.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral( activecollectioname),true);
  759.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  760.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  761.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  762.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  763.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);
  764.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral(imagebackgroundColor),true);
  765.             
  766.             var mainSeq=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,"")))+"backs"));
  767.         
  768.             mainSeq.AppendElement(newnode);
  769.  
  770.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  771.         
  772.         },
  773.         
  774.         addImageResourceNodeToCollectionDatabase: function (filename) {
  775.  
  776.             var imagename = PersonasWindow.actualfilename.replace(/\.\w+$/,"");
  777.             var imagelocation = PersonasWindow.getTheLeafNameFromFileNameString(filename);
  778.             var imagedescription = "undefined";
  779.             var imageposition = "CENTER";
  780.             var activecollectioname=filename.split("/")[0];
  781.             var imageversion="0.1";
  782.             var imageuploaded="false";
  783.             var imagesiteURI="null".replace(/&/g,"&");
  784.             var imagesource="local";
  785.             var imagescreenRes=screen.width+"x"+screen.height;
  786.             var imagebackgroundColor=PersonasWindow.retrieveDesktopBackgroundColor();
  787.             
  788.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(filename)));
  789.  
  790.             var newnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  791.             
  792.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  793.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( "false" ),true);
  794.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  795.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  796.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  797.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral( activecollectioname),true);
  798.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  799.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  800.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  801.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  802.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);
  803.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral( imagebackgroundColor),true);
  804.             
  805.             var mainSeq=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,"")))+"backs"));
  806.         
  807.             mainSeq.AppendElement(newnode);
  808.  
  809.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  810.  
  811.         },
  812.  
  813.         updatePersonaPositionForTheImageOnLibraryRdf:function(filename) {
  814.         
  815.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  816.             
  817.             var leafName=PersonasWindow.getTheLeafNameFromFileNameString(filename);
  818.  
  819.             var theImageNode = PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  820.             
  821.             var positionPredicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  822.         
  823.             var positiontarget=ds.GetTarget(theImageNode,positionPredicate,true);
  824.             
  825.             if (positiontarget!=null) var position= positiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  826.             else {return}
  827.             
  828.             var newposition="CENTER";
  829.             
  830.             var predicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  831.             var oldtarget=PersonasRotatorRDF.rdfService.GetLiteral(position);
  832.             var newtarget=PersonasRotatorRDF.rdfService.GetLiteral(newposition);
  833.             
  834.             ds.Change(theImageNode,predicate,oldtarget,newtarget);
  835.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();    
  836.  
  837.         },
  838.         
  839.         updatePersonaPositionForTheImageOnCollectionRdf:function(filename) {
  840.             
  841.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(filename)));
  842.             
  843.             var leafName=PersonasWindow.getTheLeafNameFromFileNameString(filename);
  844.  
  845.             var theImageNode = PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  846.             
  847.             var positionPredicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  848.  
  849.             var positiontarget=ds.GetTarget(theImageNode,positionPredicate,true);
  850.             
  851.             if (positiontarget!=null) var position= positiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  852.             else {return}
  853.             
  854.             var newposition="CENTER";
  855.             
  856.             var predicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  857.             var oldtarget=PersonasRotatorRDF.rdfService.GetLiteral(position);
  858.             var newtarget=PersonasRotatorRDF.rdfService.GetLiteral(newposition);
  859.             
  860.             ds.Change(theImageNode,predicate,oldtarget,newtarget);
  861.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  862.  
  863.         },
  864.         
  865.         getTheURIFromFileName:function(filename) {
  866.         
  867.             var namesplitarray=filename.split("/");
  868.             
  869.             var file=Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
  870.  
  871.             file.append("personasrotator");
  872.                     
  873.             for (var i=0;i<namesplitarray.length;i++) {
  874.             
  875.                 file.append(namesplitarray[i]);
  876.             
  877.             }
  878.             
  879.             var ios=Components.classes["@mozilla.org/network/io-service;1"]
  880.                                 .getService(Components.interfaces.nsIIOService);
  881.             var URL=ios.newFileURI(file);
  882.  
  883.             return URL.spec;
  884.             
  885.         },
  886.             
  887.         createOtherImageRequirements:function (filename) {
  888.             
  889.             PersonasWindow.appendTheNewImageToCollection(filename);
  890.         
  891.             if (PersonasWindow.updateModeOn==true) {
  892.             
  893.                 PersonasWindow.arrayinc++;
  894.             
  895.                 if(PersonasWindow.arrayinc==PersonasWindow.paths.length) {
  896.             
  897.                     PersonasWindow.refreshWindowOpenerProperties(filename);
  898.                     PersonasWindow.arrayinc=0;
  899.                     PersonasWindow.paths=[];
  900.                     PersonasWindow.updateModeOn=false;
  901.                     PersonasWindow.additemsstate=false;
  902.                     
  903.                 }
  904.             
  905.                 else {
  906.         
  907.                     PersonasWindow.starto();
  908.  
  909.                 }
  910.             
  911.             }
  912.             
  913.             else {
  914.  
  915.                 PersonasWindow.refreshWindowOpenerProperties(filename);
  916.             
  917.             }
  918.             
  919.         },
  920.             
  921.         appendTheNewImageToCollection:function(filename) {
  922.         
  923.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  924.  
  925.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  926.             
  927.             var imageResource = PersonasRotatorRDF.rdfService.GetResource(uri);
  928.  
  929.             
  930.             var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  931.             var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  932.             if (imagenametarget) {
  933.                 var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  934.             }                            
  935.             
  936.             var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  937.             var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  938.             if (imagetagstarget) {
  939.                 var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  940.             }                            
  941.  
  942.             var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  943.             var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  944.             if (imagedescriptiontarget) {
  945.                 var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  946.             }                            
  947.             
  948.             var imagelocationPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#location");
  949.             var imagelocationtarget=ds.GetTarget(imageResource,imagelocationPredicate,true);
  950.             if (imagelocationtarget) {
  951.                 var imagelocation = imagelocationtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  952.                 imagelocation = filename.split("/")[0]+"/Thumbs/Thumb_"+imagelocation;
  953.             }                            
  954.             
  955.             var node=PersonasWindow.createPersonaComponents(imagelocation,imagename);
  956.             
  957.             document.getElementsByClassName("active")[0].appendChild(node);
  958.             
  959.             var aScrollboxElement = document.getElementById('personapools');
  960.             var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  961.             
  962.             var totalpersonasnumber=document.getElementsByClassName("active")[0].childNodes.length;
  963.             
  964.             window.setTimeout(function(){
  965.                 if((totalpersonasnumber%3)==0) xpcomInterface.scrollTo(0,((totalpersonasnumber/3)*155));
  966.                 if((totalpersonasnumber%3)==1) xpcomInterface.scrollTo(0,(Math.round((totalpersonasnumber/3)+0.33)*155));
  967.                 if((totalpersonasnumber%3)==2) xpcomInterface.scrollTo(0,(Math.round((totalpersonasnumber/3))*155));
  968.             },0);
  969.         
  970.         },
  971.  
  972.         refreshWindowOpenerProperties:function(filename) {
  973.                 
  974.             var imagelocation = filename;
  975.             
  976.             var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  977.                                .getService(Components.interfaces.nsIWindowMediator);
  978.             var enumerator = wm.getEnumerator("navigator:browser");
  979.             
  980.             var windows=[];
  981.         
  982.             while(enumerator.hasMoreElements()) {
  983.  
  984.                 win = enumerator.getNext();
  985.                 windows.push(win);
  986.  
  987.             }
  988.         
  989.             if (windows.length!=0){
  990.  
  991.                 windows[0].PersonasRotator.personaimagesarraymaker();
  992.             
  993.             }
  994.         
  995.             else {
  996.             
  997.                 //do nothing
  998.             
  999.             }
  1000.         
  1001.             for (var i=0;i<windows.length;i++) {
  1002.             
  1003.                 if (i==0) continue;
  1004.  
  1005.                     windows[i].PersonasRotator.personasrotator=windows[0].PersonasRotator.personasrotator;
  1006.             }
  1007.             
  1008.             if (window.opener!=undefined && window.opener.PersonasRotator!=undefined){
  1009.             
  1010.                 window.opener.PersonasRotator.currentimagefilename=imagelocation;
  1011.                 
  1012.                 window.opener.PersonasRotator.imagespecified='yes';
  1013.                 
  1014.                 window.opener.PersonasRotator.newimage.src=PersonasWindow.assignFileURIToImage(imagelocation);
  1015.             
  1016.             }
  1017.             
  1018.             else {
  1019.                 
  1020.                 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  1021.                                    .getService(Components.interfaces.nsIWindowMediator);
  1022.                 var enumerator = wm.getEnumerator("navigator:browser");
  1023.                 
  1024.                 var win=null;
  1025.                 
  1026.                 while(enumerator.hasMoreElements()) {
  1027.  
  1028.                     win = enumerator.getNext();
  1029.  
  1030.                     break;
  1031.  
  1032.                 }
  1033.                 
  1034.                 if (win!=null){
  1035.                     
  1036.                     win.PersonasRotator.currentimagefilename=imagelocation;
  1037.                     
  1038.                     win.PersonasRotator.imagespecified='yes';
  1039.                     
  1040.                     win.PersonasRotator.newimage.src=PersonasWindow.assignFileURIToImage(imagelocation);
  1041.                 
  1042.                 }
  1043.                 
  1044.                 else {
  1045.                 
  1046.                     //do nothing
  1047.                 
  1048.                 }
  1049.         
  1050.             }
  1051.                 
  1052.         },
  1053.     
  1054.         createAlertPrompt:function(promptString){
  1055.             
  1056.             var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  1057.                                     
  1058.             prompt.alert(null,"Personas Rotator",promptString);
  1059.  
  1060.         
  1061.         },
  1062.         
  1063.         createPromptPrompt:function(promptString){
  1064.             
  1065.             var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  1066.             
  1067.             var input = {value:""}; 
  1068.             
  1069.             var check = {value:false};
  1070.  
  1071.             var result= prompt.prompt(null,"Personas Rotator",promptString,input,null,check);
  1072.             
  1073.             if(result==false) return null;
  1074.             else return input.value;
  1075.             
  1076.         },
  1077.         
  1078.         createConfirmPrompt:function(promptString){
  1079.             
  1080.             var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);            
  1081.             
  1082.             return prompt.confirm(null,"Personas Rotator",promptString);
  1083.  
  1084.         },
  1085.  
  1086.         additems:function () {
  1087.             
  1088.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;}
  1089.             
  1090.             const nsIFilePicker=Components.interfaces.nsIFilePicker;
  1091.  
  1092.             var filepicker=Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  1093.                            
  1094.             filepicker.init(window,PersonasWindow.STRINGS.getString("choosePersonas"),nsIFilePicker.modeOpenMultiple);
  1095.             
  1096.             filepicker.appendFilters(nsIFilePicker.filterImages );
  1097.  
  1098.             var returnvalue=filepicker.show();
  1099.  
  1100.             if (returnvalue==nsIFilePicker.returnOK || returnvalue==nsIFilePicker.returnReplace) {
  1101.                 
  1102.                 var chosenfiles = filepicker.files;
  1103.            
  1104.                 while (chosenfiles.hasMoreElements()) {
  1105.                 
  1106.                     var arg=chosenfiles.getNext().QueryInterface(Components.interfaces.nsILocalFile);
  1107.                     PersonasWindow.paths.push(arg);
  1108.                 
  1109.                 }
  1110.  
  1111.                 if(PersonasWindow.paths.length>15) {
  1112.                 
  1113.                     if(!PersonasWindow.createConfirmPrompt(PersonasWindow.STRINGS.getString("moreThan15Confirm"))) {PersonasWindow.paths=[];return;}
  1114.                 
  1115.                 }
  1116.                 
  1117.                 PersonasWindow.additemsstate=true;
  1118.                 
  1119.                 PersonasWindow.updateModeOn=true;
  1120.                 
  1121.                 PersonasWindow.starto();
  1122.              
  1123.             }
  1124.  
  1125.         },
  1126.         
  1127.         starto:function () {
  1128.  
  1129.             var filechosen = PersonasWindow.paths[PersonasWindow.arrayinc]; 
  1130.         
  1131.             PersonasWindow.processFilesForAddition(filechosen);
  1132.                 
  1133.         },        
  1134.         
  1135.         createnewcollection:function () {
  1136.         
  1137.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};    
  1138.                         
  1139.             var promptwarning=PersonasWindow.STRINGS.getString("giveCollectionName");
  1140.             
  1141.             var name="";
  1142.             
  1143.             function validate(passedname) {
  1144.             
  1145.             name=passedname;
  1146.             
  1147.             if (name==null) return null;
  1148.             
  1149.             name=name.replace(/^\s+|\s+$/g, '');
  1150.             
  1151.             while (name=="") {
  1152.             
  1153.                 name=PersonasWindow.createPromptPrompt(PersonasWindow.STRINGS.getString("giveCollectionName"));
  1154.                 
  1155.                 if (name==null) return null;
  1156.                 
  1157.                 name=name.replace(/^\s+|\s+$/g, '');
  1158.             
  1159.             }
  1160.             
  1161.             while (name.search(/[\\\/:*?"<>|]/g)!=-1) {
  1162.                 
  1163.                 name=PersonasWindow.createPromptPrompt(PersonasWindow.STRINGS.getString("invalidCharacter"));
  1164.                 
  1165.                 if (name==null) return null;
  1166.                 
  1167.                 name=name.replace(/^\s+|\s+$/g, '');
  1168.                 
  1169.                 while (name=="") {
  1170.                     name=PersonasWindow.createPromptPrompt(PersonasWindow.STRINGS.getString("giveCollectionName"));
  1171.                     
  1172.                     
  1173.                     if (name==null) return null;
  1174.                     
  1175.                     name=name.replace(/^\s+|\s+$/g, '');
  1176.                 }
  1177.                 
  1178.             }        
  1179.                 
  1180.             return name;            
  1181.                 
  1182.             }
  1183.  
  1184.             function checkCollectionNameCollision(passedname){
  1185.                 
  1186.                 if (passedname==null) return false;
  1187.                 
  1188.                 var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  1189.  
  1190.                 var container=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:library"));
  1191.                 var genericpersonasseqenumurator=container.GetElements();
  1192.                 var namePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  1193.  
  1194.                 while (genericpersonasseqenumurator.hasMoreElements()) {
  1195.             
  1196.                     var collection=genericpersonasseqenumurator.getNext();
  1197.                     
  1198.                     
  1199.                     var nametarget=ds.GetTarget(collection,namePredicate,true);
  1200.                 
  1201.                     if (nametarget) {
  1202.                         
  1203.                         var name = nametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  1204.  
  1205.                     }
  1206.                     
  1207.                     var collectionname=name;
  1208.                     
  1209.                     if (collectionname.toLowerCase()==passedname.toLowerCase()) {return true}
  1210.             
  1211.                 }
  1212.                 
  1213.                 return false;
  1214.  
  1215.             }
  1216.  
  1217.             while (checkCollectionNameCollision(validate(PersonasWindow.createPromptPrompt(promptwarning)))){
  1218.  
  1219.                 promptwarning=PersonasWindow.STRINGS.getFormattedString("sameCollectionName",[name]);
  1220.  
  1221.             }
  1222.             
  1223.             if (name==null) return ;
  1224.             
  1225.             PersonasWindow.changeDOMForNewCollectionAddition(name);
  1226.             
  1227.             PersonasWindow.addNewEmptyCollectionToDatabase(name);
  1228.             
  1229.             PersonasWindow.createNewCollectionDirectories(name);
  1230.             
  1231.             PersonasWindow.createNewCollectionCollecitonRDFFile(name);
  1232.             
  1233.         },
  1234.         
  1235.         removeClass : function(domnode, passedclass){
  1236.  
  1237.             var searchpattern = new RegExp("( |^)"+passedclass+"($| )");
  1238.             var classtring=domnode.className;
  1239.             classtring=classtring.replace(searchpattern, "$1");
  1240.             classtring=classtring.replace(/ $/, "");
  1241.             domnode.className=classtring;
  1242.  
  1243.         },
  1244.         
  1245.         changeDOMForNewCollectionAddition: function (name) {
  1246.         
  1247.         if(PersonasWindow.hasClass(document.getElementById("deleteinfo"),"infovisible")) PersonasWindow.removeClass(document.getElementById("deleteinfo"),"infovisible");
  1248.  
  1249.         var newbutton=document.createElement("label");
  1250.  
  1251.         newbutton.setAttribute("value",name);
  1252.         
  1253.         newbutton.setAttribute("crop","end");
  1254.         
  1255.         newbutton.setAttribute("id",encodeURI(name)+"button");
  1256.         
  1257.         newbutton.setAttribute("onclick","PersonasWindow.clickhandle(event);");
  1258.         
  1259.         newbutton.setAttribute("context","button-popup");
  1260.         
  1261.         newbutton.setAttribute("class","collection-button");
  1262.         
  1263.         newbutton.setAttribute("clicked","true");
  1264.         
  1265.         document.getElementById("collectionscolumn").appendChild(newbutton);
  1266.         
  1267.         document.getElementById("collectionscolumn").appendChild(newbutton);
  1268.         
  1269.         var newhtmldiv=document.createElementNS("http://www.w3.org/1999/xhtml","html:div");
  1270.         
  1271.         newhtmldiv.setAttribute("id",encodeURI(name)+"htmldiv");
  1272.         
  1273.         newhtmldiv.setAttribute("class","htmldiv");
  1274.         
  1275.         var addedhtmldiv=document.getElementById("gallerystack").appendChild(newhtmldiv);
  1276.         
  1277.         if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  1278.         if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  1279.         
  1280.         if(PersonasWindow.editstate==true) {
  1281.         
  1282.             var edithtmldiv=document.getElementsByClassName("edithtmldiv")[0];
  1283.             
  1284.             edithtmldiv.parentNode.removeChild(edithtmldiv);
  1285.             
  1286.             PersonasWindow.editstate=false;
  1287.             
  1288.         }            
  1289.  
  1290.         if(!PersonasWindow.hasClass(document.getElementById("editnavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("editnavbuttons"),"buttoninactive");}
  1291.             
  1292.         PersonasWindow.addClass(addedhtmldiv,"active");
  1293.         PersonasWindow.removeClass(addedhtmldiv,"inactive");
  1294.         
  1295.         if(PersonasWindow.hasClass(document.getElementById("gallerynavbuttons"),"buttoninactive")) {PersonasWindow.removeClass(document.getElementById("gallerynavbuttons"),"buttoninactive");}
  1296.  
  1297.         if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("activecollectionbutton")[0],"activecollectionbutton");
  1298.  
  1299.         PersonasWindow.addClass(newbutton,"activecollectionbutton");                                            
  1300.         
  1301.         if(!PersonasWindow.hasClass(document.getElementById("newsheading"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("newsheading"),"buttoninactive");}
  1302.         
  1303.         if(!PersonasWindow.hasClass(document.getElementById("newshtmldiv"),"inactive")) {
  1304.         
  1305.             PersonasWindow.addClass(document.getElementById("newshtmldiv"),"inactive");
  1306.             PersonasWindow.removeClass(document.getElementById("newshtmldiv"),"active");
  1307.         
  1308.         }
  1309.         
  1310.         },
  1311.         
  1312.         addNewEmptyCollectionToDatabase:function (name) {
  1313.  
  1314.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  1315.  
  1316.             var newnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(name));
  1317.             
  1318.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#relateduri" ),PersonasRotatorRDF.rdfService.GetLiteral( "urn:personasrotator:"+PersonasWindow.createEncodedName(name)+"backs"),true);
  1319.             ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( name ),true);
  1320.             
  1321.             var mainSeq=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:library"));
  1322.             mainSeq.AppendElement(newnode);
  1323.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();    
  1324.         
  1325.         },
  1326.         
  1327.         createNewCollectionDirectories:function(name){
  1328.         
  1329.             var mainDirectory=PersonasWindow.getMainPersonaDirectory();
  1330.             
  1331.             var mainCollectionDirectory=mainDirectory;
  1332.             mainCollectionDirectory.append(name);
  1333.             PersonasWindow.createNewDirectoriesForNewCollection(mainCollectionDirectory);
  1334.  
  1335.             mainCollectionDirectory.append("Personas");
  1336.             var mainCollectionPersonasDirectory=mainCollectionDirectory;
  1337.             PersonasWindow.createNewDirectoriesForNewCollection(mainCollectionPersonasDirectory);    
  1338.             
  1339.             var mainCollectionThumbsDirectory=PersonasWindow.getMainPersonaDirectory();
  1340.             mainCollectionThumbsDirectory.append(name);
  1341.             mainCollectionThumbsDirectory.append("Thumbs");
  1342.             PersonasWindow.createNewDirectoriesForNewCollection(mainCollectionThumbsDirectory);    
  1343.         
  1344.             var mainCollectionRDFsDirectory=PersonasWindow.getMainPersonaDirectory();
  1345.             mainCollectionRDFsDirectory.append(name);
  1346.             mainCollectionRDFsDirectory.append("RDFs");
  1347.             PersonasWindow.createNewDirectoriesForNewCollection(mainCollectionRDFsDirectory);    
  1348.         
  1349.         },
  1350.  
  1351.         getMainPersonaDirectory:function() {
  1352.                     
  1353.             var file = Components.classes["@mozilla.org/file/directory_service;1"]
  1354.                                  .getService(Components.interfaces.nsIProperties)
  1355.                                  .get("ProfD", Components.interfaces.nsIFile);
  1356.  
  1357.             file.append("personasrotator");
  1358.  
  1359.             return file;
  1360.         
  1361.         },
  1362.  
  1363.         createNewDirectoriesForNewCollection:function(directory){
  1364.         
  1365.             if(!directory.exists()) {
  1366.             
  1367.                 try {
  1368.                     directory.create(0x01, 0775);//for linux, directories need to be created with 775 permission
  1369.                     return true;
  1370.                 }
  1371.                 catch(e) {
  1372.                     PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("permissionDenied"));                    
  1373.                     return false;
  1374.                 }
  1375.                 
  1376.             }
  1377.             
  1378.         },
  1379.  
  1380.         createNewCollectionCollecitonRDFFile:function(name){
  1381.         
  1382.             var mainDirectory=PersonasWindow.getMainPersonaDirectory();
  1383.         
  1384.             mainDirectory.append(name);
  1385.             
  1386.             mainDirectory.append("Collection.rdf");
  1387.  
  1388.             var RDFstring='<?xml version="1.0"?>'+'<RDF:RDF xmlns:personasrotator="urn:personasrotator#" xmlns:NC="http://home.netscape.com/NC-rdf#" xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'+'<RDF:Seq RDF:about="urn:personasrotator:'+PersonasWindow.createEncodedName(name).replace(/&/g,"&")+'backs"></RDF:Seq>'+'</RDF:RDF>';
  1389.             
  1390.             PersonasRotatorFileIO.write(mainDirectory,RDFstring,"w","UTF-8");
  1391.             
  1392.         },
  1393.  
  1394.         deletebutton:function (node) {
  1395.         
  1396.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  1397.             
  1398.             var chosenbuttonname=node.getAttribute("id").replace(/button$/,"");
  1399.             
  1400.             var relatedhtmldiv=document.getElementById(chosenbuttonname+"htmldiv");
  1401.             
  1402.             var collectionname=decodeURI(chosenbuttonname)
  1403.         
  1404.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  1405.             
  1406.             var relatedcollection=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+(PersonasWindow.createEncodedName(collectionname))+"backs"));
  1407.             var collectionsseqenumurator=relatedcollection.GetElements();
  1408.             
  1409.             var totalpersonasnumber=0;
  1410.             
  1411.             while (collectionsseqenumurator.hasMoreElements()) {
  1412.             
  1413.                 collectionsseqenumurator.getNext();
  1414.                 totalpersonasnumber++;
  1415.             
  1416.             }        
  1417.         
  1418.             var confirmtext="Collection will be removed.";
  1419.             
  1420.             if (totalpersonasnumber>0) { 
  1421.             
  1422.             confirmtext+=" Personas that belongs to this collection will be removed, too.\nWould you like to continue?";
  1423.             
  1424.             }
  1425.             
  1426.             else {
  1427.             
  1428.             confirmtext+="Would you like to continue?";
  1429.             
  1430.             }
  1431.  
  1432.             var response=PersonasWindow.createConfirmPrompt(confirmtext);
  1433.             
  1434.             if (response==false) return;
  1435.             
  1436.             node.parentNode.removeChild(node);
  1437.             
  1438.             relatedhtmldiv.parentNode.removeChild(relatedhtmldiv);
  1439.  
  1440.             var activecollectionname=decodeURI(chosenbuttonname);
  1441.             
  1442.             PersonasWindow.handleCollectionReatedResourceNodesDeletion(activecollectionname);
  1443.             
  1444.             var mainDirectory=PersonasWindow.getMainPersonaDirectory();
  1445.             mainDirectory.append(activecollectionname);
  1446.             mainDirectory.remove(true);
  1447.             
  1448.             PersonasWindow.handlePersonasWindowPropertiesAfterPersonaImageDeletes();
  1449.             
  1450.             PersonasWindow.refreshWindowOpenerAfterPersonaImageDelete();
  1451.             
  1452.         },
  1453.             
  1454.         handleCollectionReatedResourceNodesDeletion: function(activecollectionname){
  1455.         
  1456.         var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  1457.         var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(activecollectionname);
  1458.         var rdfnode = PersonasRotatorRDF.rdfService.GetResource(uri);
  1459.         var resourceNode=rdfnode;
  1460.         
  1461.         PersonasWindow.removeChildren(ds,resourceNode,false);
  1462.         
  1463.         var predicatesIn=ds.ArcLabelsIn(resourceNode);
  1464.         while (predicatesIn.hasMoreElements()){
  1465.           
  1466.             var predicateIn=predicatesIn.getNext();
  1467.             var source=ds.GetSource(predicateIn,resourceNode,true);
  1468.             ds.Unassert(source,predicateIn,resourceNode);
  1469.  
  1470.         }    
  1471.         
  1472.         var collectionnode=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(activecollectionname)+"backs");
  1473.         var resourceNode2=collectionnode;
  1474.             
  1475.         PersonasWindow.removeChildren(ds,resourceNode2,false);
  1476.         
  1477.         var predicatesIn2=ds.ArcLabelsIn(resourceNode2);
  1478.         while (predicatesIn2.hasMoreElements()){
  1479.           
  1480.             var predicateIn2=predicatesIn2.getNext();
  1481.             var source2=ds.GetSource(predicateIn2,resourceNode2,true);
  1482.             ds.Unassert(source2,predicateIn2,resourceNode2);
  1483.  
  1484.         }    
  1485.         
  1486.         ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();        
  1487.  
  1488.         },    
  1489.             
  1490.         handlePersonasWindowPropertiesAfterPersonaImageDeletes: function(){
  1491.  
  1492.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  1493.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  1494.             if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined)  PersonasWindow.removeClass(document.getElementsByClassName("activecollectionbutton")[0],"activecollectionbutton");
  1495.             if(!PersonasWindow.hasClass(document.getElementById("gallerynavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("gallerynavbuttons"),"buttoninactive");}
  1496.             
  1497.             if(!PersonasWindow.hasClass(document.getElementById("newsheading"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("newsheading"),"buttoninactive");}
  1498.  
  1499.             if(PersonaWindowSelectManager.highlighteds.length>0){
  1500.                 
  1501.                 if(PersonaWindowSelectManager.highlighteds[0].parentNode.parentNode.id.replace(/htmldiv$/,"")==document.popupNode.id.replace(/button$/,"")) PersonaWindowSelectManager.highlighteds=[];
  1502.             
  1503.             }
  1504.             
  1505.             PersonasWindow.addClass(document.getElementById("deleteinfo"),"infovisible");
  1506.         
  1507.             },
  1508.             
  1509.         refreshWindowOpenerAfterPersonaImageDelete: function(){        
  1510.                 
  1511.             var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  1512.                                .getService(Components.interfaces.nsIWindowMediator);
  1513.             var enumerator = wm.getEnumerator("navigator:browser");
  1514.             
  1515.             var windows=[];
  1516.             
  1517.             var win;
  1518.         
  1519.             while(enumerator.hasMoreElements()) {
  1520.  
  1521.                 win = enumerator.getNext();
  1522.                 windows.push(win);
  1523.  
  1524.             }
  1525.         
  1526.             if (windows.length!=0){
  1527.  
  1528.                 windows[0].PersonasRotator.personaimagesarraymaker();
  1529.                 windows[0].PersonasRotator.imagespecified='no'; 
  1530.             }
  1531.         
  1532.             else {
  1533.             
  1534.             //do nothing
  1535.             
  1536.             }
  1537.         
  1538.             for (var i=0;i<windows.length;i++) {
  1539.             
  1540.                 if (i==0) continue;
  1541.  
  1542.                     windows[i].PersonasRotator.personasrotator=windows[0].PersonasRotator.personasrotator;
  1543.                     windows[i].PersonasRotator.imagespecified='no'; 
  1544.             
  1545.             }
  1546.  
  1547.         },        
  1548.  
  1549.         deleteitem:function (node,last) {
  1550.             
  1551.              if (last == null){
  1552.              
  1553.                 last=false;
  1554.                 
  1555.             }
  1556.             
  1557.             var chosenthumbfilename=decodeURI(node.getAttribute("src").split(PersonasWindow.personaImagePreName)[1]); 
  1558.  
  1559.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  1560.             
  1561.             PersonasWindow.removePersonaImageFile(filename);
  1562.             
  1563.             PersonasWindow.removePersonaImageindividualRDFFile(filename);
  1564.             
  1565.             PersonasWindow.removePersonaImageThumbFile(filename);
  1566.             
  1567.             PersonasWindow.removeRelatedImageNodeFromLibraryDatabase(filename);
  1568.             
  1569.             PersonasWindow.removeRelatedImageNodeFromCollectionDatabase(filename);
  1570.  
  1571.             PersonasWindow.removeImageFromCollectionDOMTree(node.parentNode,"delete");
  1572.             
  1573.             if (last==true) {PersonasWindow.refreshWindowOpenerAfterPersonaImageDelete();}
  1574.  
  1575.             PersonasWindow.arrayinc--;
  1576.             
  1577.             PersonasWindow.deleteitemstart();
  1578.             
  1579.         },
  1580.         
  1581.         createPersonaImageNameFromThumbImageName:function(chosenthumbfilename){
  1582.  
  1583.             var namesplitarray=chosenthumbfilename.split("/");
  1584.         
  1585.             var createdFileName="";
  1586.             
  1587.             for (var i=0;i<namesplitarray.length;i++) {
  1588.             
  1589.                 if(i==namesplitarray.length-1) {createdFileName+=namesplitarray[i];break;}
  1590.                 if(i!=1) createdFileName+=namesplitarray[i]+"/";
  1591.                 else  createdFileName+="Personas/";
  1592.                 
  1593.             }
  1594.  
  1595.             return createdFileName.replace("/Thumb_","/");
  1596.             
  1597.         },
  1598.         
  1599.         removePersonaImageFile: function(filename){
  1600.  
  1601.             var file =PersonasWindow.getChromeFile(filename);    
  1602.  
  1603.             try {
  1604.             file.remove(false);
  1605.             }
  1606.             catch(err){
  1607.             Components.utils.reportError(err);
  1608.             }
  1609.  
  1610.         },
  1611.             
  1612.         removePersonaImageindividualRDFFile: function(filename){
  1613.  
  1614.         var individualRDFFilename=PersonasWindow.createIndividualRDFFilename(filename);
  1615.  
  1616.         var filex =PersonasWindow.getChromeFile(individualRDFFilename);
  1617.         
  1618.         try {
  1619.         filex.remove(false);
  1620.         }
  1621.         catch(err){
  1622.         Components.utils.reportError(err);
  1623.         }
  1624.  
  1625.         },
  1626.         
  1627.         removePersonaImageThumbFile: function(filename){
  1628.  
  1629.         var filey = PersonasWindow.getThumbFile(filename);
  1630.         try {
  1631.         filey.remove(false);
  1632.         }
  1633.         catch(err){
  1634.         Components.utils.reportError(err);
  1635.         }
  1636.         
  1637.         },
  1638.         
  1639.         removeRelatedImageNodeFromLibraryDatabase: function(filename){
  1640.         
  1641.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  1642.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  1643.             var rdfnode = PersonasRotatorRDF.rdfService.GetResource(uri);
  1644.             var resourceNode=rdfnode;
  1645.             
  1646.             PersonasWindow.removeChildren(ds,resourceNode,false);    
  1647.             
  1648.             var predicatesIn=ds.ArcLabelsIn(resourceNode);
  1649.             while (predicatesIn.hasMoreElements()){
  1650.               
  1651.                 var predicateIn=predicatesIn.getNext();
  1652.                 var source=ds.GetSource(predicateIn,resourceNode,true);
  1653.                 ds.Unassert(source,predicateIn,resourceNode);
  1654.  
  1655.             }
  1656.             
  1657.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  1658.         
  1659.         },
  1660.             
  1661.         removeChildren : function (ds,resourceNode,bool){
  1662.             
  1663.             var bool=bool;
  1664.             
  1665.             var predicates=ds.ArcLabelsOut(resourceNode);
  1666.             
  1667.             while (predicates.hasMoreElements()){
  1668.  
  1669.                 var predicate=predicates.getNext();
  1670.                 
  1671.                 var targets=ds.GetTargets(resourceNode,predicate,true);
  1672.                 
  1673.                 while (targets.hasMoreElements()) {
  1674.  
  1675.                     var target = targets.getNext();
  1676.                     
  1677.                     try {
  1678.                         
  1679.                         target=target.QueryInterface(Components.interfaces.nsIRDFResource);
  1680.                         
  1681.                         PersonasWindow.removeChildren(ds,target,false);
  1682.                         
  1683.                     }
  1684.                     catch (err){
  1685.                     
  1686.                         //foobar
  1687.                     
  1688.                     }
  1689.                     
  1690.                     ds.Unassert(resourceNode,predicate,target)
  1691.  
  1692.                 }
  1693.  
  1694.             }    
  1695.             
  1696.         },
  1697.             
  1698.         removeRelatedImageNodeFromCollectionDatabase: function(filename){
  1699.  
  1700.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(filename)));    
  1701.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  1702.             var rdfnode = PersonasRotatorRDF.rdfService.GetResource(uri);
  1703.             var resourceNode=rdfnode;
  1704.             
  1705.             PersonasWindow.removeChildren(ds,resourceNode,false);
  1706.             
  1707.             var predicatesIn=ds.ArcLabelsIn(resourceNode);
  1708.             while (predicatesIn.hasMoreElements()){
  1709.               
  1710.                 var predicateIn=predicatesIn.getNext();
  1711.                 var source=ds.GetSource(predicateIn,resourceNode,true);
  1712.                 ds.Unassert(source,predicateIn,resourceNode);
  1713.  
  1714.             }
  1715.             
  1716.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  1717.  
  1718.         },    
  1719.         
  1720.         removeImageFromCollectionDOMTree: function(node,mode){
  1721.     
  1722.             var index;
  1723.             
  1724.             for (var i=0;i<node.parentNode.childNodes.length;i++){
  1725.                 
  1726.                 if(node.parentNode.childNodes[i]==node) index=i+1;
  1727.                 
  1728.             }
  1729.             
  1730.             var bool=(node.parentNode.childNodes.length%3==1);
  1731.             var parentNode=node.parentNode;
  1732.             
  1733.             var aScrollboxElement = document.getElementById('personapools');
  1734.             var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  1735.             
  1736.             var extend=mode=="cut" ? 3 : 1;
  1737.  
  1738.             if((index%3)==0) xpcomInterface.scrollTo(0,((index/3-extend)*155));
  1739.             if((index%3)==1) xpcomInterface.scrollTo(0,(Math.round((index/3-extend)+0.33)*155));
  1740.             if((index%3)==2) xpcomInterface.scrollTo(0,(Math.round((index/3-extend))*155));
  1741.             
  1742.             node.parentNode.removeChild(node);
  1743.  
  1744.         },        
  1745.         
  1746.         createCollectionRDfFileName:function(filename) {
  1747.         
  1748.             return filename.split("/")[0]+"/"+"Collection.rdf";
  1749.         
  1750.         },
  1751.  
  1752.         clickhandle:function (event) {
  1753.  
  1754.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  1755.         
  1756.             if(event.button==2) return;
  1757.             
  1758.             var visibleInfoDivs=document.getElementsByClassName("infovisible");
  1759.             
  1760.             for (var i=0;i<visibleInfoDivs.length;i++) {
  1761.                 
  1762.                 PersonasWindow.removeClass(visibleInfoDivs[i],"infovisible");
  1763.                 
  1764.             }    
  1765.         
  1766.             if(PersonasWindow.fillspacestate==true) {
  1767.                 
  1768.                 if(PersonasWindow.fillspaceadditemsettimeoutid!=null) {
  1769.                 
  1770.                     window.clearTimeout(PersonasWindow.fillspaceadditemsettimeoutid);
  1771.                 
  1772.                 }
  1773.  
  1774.                 if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined) document.getElementsByClassName("activecollectionbutton")[0].setAttribute("fillspaceleft",PersonasWindow.arrayinc);
  1775.                 
  1776.                 PersonasWindow.updateModeOn=false;
  1777.                 PersonasWindow.fillspacestate=false;
  1778.                 
  1779.             };    
  1780.             
  1781.             PersonasWindow.removeClass(document.getElementById("progressinfo"),"infovisible");
  1782.             
  1783.             var aScrollboxElement=document.getElementById('personapools');
  1784.             var xpcomInterface=aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  1785.             xpcomInterface.scrollTo(0, 0);
  1786.         
  1787.             if(PersonasWindow.editstate==true) {
  1788.             
  1789.                 var edithtmldiv=document.getElementsByClassName("edithtmldiv")[0];
  1790.                 
  1791.                 edithtmldiv.parentNode.removeChild(edithtmldiv);
  1792.                 
  1793.                 PersonasWindow.editstate=false;
  1794.                 
  1795.             }
  1796.             
  1797.             if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("activecollectionbutton")[0],"activecollectionbutton");
  1798.  
  1799.             PersonasWindow.addClass(event.target,"activecollectionbutton");
  1800.  
  1801.             if(PersonasWindow.hasClass(document.getElementById("gallerynavbuttons"),"buttoninactive")) {PersonasWindow.removeClass(document.getElementById("gallerynavbuttons"),"buttoninactive");}
  1802.         
  1803.             if(!PersonasWindow.hasClass(document.getElementById("editnavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("editnavbuttons"),"buttoninactive");}
  1804.  
  1805.             if(!PersonasWindow.hasClass(document.getElementById("newsheading"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("newsheading"),"buttoninactive");}
  1806.             
  1807.             if (!PersonasWindow.hasClass(document.getElementById(event.target.getAttribute("id").replace(/button$/,"")+"htmldiv"),"active")) {
  1808.                 
  1809.                 if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  1810.                 if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  1811.  
  1812.                 PersonasWindow.addClass(document.getElementById(event.target.getAttribute("id").replace(/button$/,"")+"htmldiv"),"active");
  1813.                 PersonasWindow.removeClass(document.getElementById(event.target.getAttribute("id").replace(/button$/,"")+"htmldiv"),"inactive");
  1814.  
  1815.             }
  1816.  
  1817.             if (event.target.getAttribute("clicked")!="true" || event.target.hasAttribute("fillspaceleft")) {
  1818.                 
  1819.                 PersonasWindow.addClass(document.getElementById("progressinfo"),"infovisible");
  1820.                 
  1821.                 if(event.target.getAttribute("clicked")!="true") event.target.setAttribute("clicked","true");
  1822.  
  1823.                 PersonasWindow.fillspace(decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,"")));
  1824.  
  1825.             }
  1826.             
  1827.             if(event.target.getAttribute("clicked")!="true") event.target.setAttribute("clicked","true");
  1828.     
  1829.         },
  1830.         
  1831.         fillspace:function (activecollectionnamepassed) {
  1832.         
  1833.             PersonasWindow.fillspacestate=true;
  1834.             
  1835.             if (document.getElementById(encodeURI(activecollectionnamepassed)+"button").hasAttribute("fillspaceleft")) {
  1836.                             
  1837.                 PersonasWindow.arrayinc=parseInt(document.getElementsByClassName("activecollectionbutton")[0].getAttribute("fillspaceleft"));
  1838.             
  1839.             }
  1840.             
  1841.             else {
  1842.             
  1843.                 PersonasWindow.arrayinc=0;
  1844.             
  1845.             }
  1846.             
  1847.             var activecollectionname=activecollectionnamepassed;
  1848.                         
  1849.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  1850.             var container=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(activecollectionname)+"backs"));
  1851.             var genericpersonaslienumurator=container.GetElements();
  1852.             
  1853.             PersonasWindow.personasarray=[];
  1854.             
  1855.             var inc=0;
  1856.             
  1857.             while (genericpersonaslienumurator.hasMoreElements()) {
  1858.  
  1859.                 var genericpersonas=genericpersonaslienumurator.getNext();
  1860.                 
  1861.                 var imageResource=genericpersonas;
  1862.                 
  1863.                 var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  1864.                 var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  1865.                 if (imagenametarget) {
  1866.                     var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  1867.                 }        
  1868.             
  1869.                 var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  1870.                 var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  1871.                 if (imagedescriptiontarget) {
  1872.                     var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  1873.                 }        
  1874.                                     
  1875.                 var imagelocationPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#location");
  1876.                 var imagelocationtarget=ds.GetTarget(imageResource,imagelocationPredicate,true);
  1877.                 if (imagelocationtarget) {
  1878.                     var imagelocation = imagelocationtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  1879.                     imagelocation = activecollectionname+"/Thumbs/Thumb_"+imagelocation;
  1880.                 }
  1881.                 
  1882.                 var persona=[];
  1883.                 persona["activecollectionname"]=activecollectionname;
  1884.                 persona["imagelocation"]=imagelocation;
  1885.                 persona["imagename"]=imagename;
  1886.                 
  1887.                 PersonasWindow.personasarray.push(persona);
  1888.             
  1889.             }
  1890.             
  1891.             PersonasWindow.fillspaceadditemstart();
  1892.  
  1893.         },
  1894.         
  1895.         fillspaceadditemstart:function(){
  1896.         
  1897.             if(PersonasWindow.arrayinc==PersonasWindow.personasarray.length) {
  1898.             
  1899.                 if(PersonasWindow.fillspacebackuparray.length!=0){
  1900.                 
  1901.                     for(var i=0;i<PersonasWindow.fillspacebackuparray.length;i++){
  1902.                     
  1903.                     document.getElementsByClassName("active")[0].appendChild(PersonasWindow.fillspacebackuparray[i]);
  1904.                     
  1905.                     }
  1906.                 
  1907.                     PersonasWindow.fillspacebackuparray=[];
  1908.             
  1909.                 }
  1910.                 
  1911.                 PersonasWindow.updateModeOn=false;
  1912.                 PersonasWindow.arrayinc=0;
  1913.                 PersonasWindow.fillspacestate=false; 
  1914.                 document.getElementsByClassName("activecollectionbutton")[0].removeAttribute("fillspaceleft");
  1915.                 PersonasWindow.removeClass(document.getElementById("progressinfo"),"infovisible");
  1916.                 return;
  1917.             
  1918.             }
  1919.     
  1920.             PersonasWindow.updateModeOn=true;
  1921.             var itemsleft=PersonasWindow.personasarray.length-PersonasWindow.arrayinc;
  1922.  
  1923.             document.getElementById("hider_div").style.backgroundPosition=(301*(PersonasWindow.arrayinc/PersonasWindow.personasarray.length))+"px top";
  1924.         
  1925.             PersonasWindow.fillspaceadditemsettimeoutid=window.setTimeout(function(){
  1926.                 
  1927.                 var persona=PersonasWindow.personasarray[PersonasWindow.arrayinc];            
  1928.                 PersonasWindow.fillspaceadditem(persona["activecollectionname"],persona["imagelocation"],persona["imagename"])
  1929.                 
  1930.             },0);
  1931.                     
  1932.         },
  1933.         
  1934.         fillspaceadditem:function(activecollectionname,imagelocation,imagename){
  1935.             
  1936.             document.getElementById(encodeURI(activecollectionname)+"htmldiv").appendChild(PersonasWindow.createPersonaComponents(imagelocation,imagename));
  1937.             PersonasWindow.arrayinc++;
  1938.             PersonasWindow.fillspaceadditemstart();
  1939.         
  1940.         },
  1941.         
  1942.         createPersonaComponents:function(imagelocation,imagename){
  1943.         
  1944.             var imagewrapperdiv=document.createElementNS("http://www.w3.org/1999/xhtml","html:div");
  1945.             imagewrapperdiv.setAttribute("class","imagewrapperdiv");
  1946.         
  1947.             var namespan = document.createElement("box");
  1948.             namespan.setAttribute("class","serdo imagespan");
  1949.             namespan.setAttribute("ondblclick","PersonasWindow.ondoubleclick(event)");
  1950.             namespan.setAttribute("onclick","PersonaWindowSelectManager.clicklistener(event)");
  1951.             namespan.appendChild(document.createTextNode(imagename));
  1952.             namespan.setAttribute("style","display:block;height:"+(document.defaultView.getComputedStyle(namespan, null).getPropertyValue("line-height"))+";");
  1953.             
  1954.             var imagenameanchor = namespan;
  1955.             
  1956.             var imageelement=document.createElement("image");
  1957.             imageelement.setAttribute("src",PersonasWindow.assignFileURIToImage(imagelocation));
  1958.             imageelement.setAttribute("class","personasrotatorimage");
  1959.             imageelement.setAttribute("onclick","PersonaWindowSelectManager.clicklistener(event)");
  1960.             
  1961.             imageelement.setAttribute("tooltiptext",imagename);
  1962.             imageelement.setAttribute("width","157");
  1963.             imageelement.setAttribute("height","150");
  1964.             imageelement.setAttribute("ondblclick","PersonasWindow.ondoubleclick(event)");
  1965.             imageelement.setAttribute("filename",imagelocation);
  1966.                     
  1967.             imagewrapperdiv.appendChild(imageelement);
  1968.             imagewrapperdiv.appendChild(imagenameanchor);
  1969.  
  1970.             return imagewrapperdiv;
  1971.                 
  1972.         },
  1973.         
  1974.         assignFileURIToImage:function(filename){
  1975.         
  1976.             if (filename==undefined || filename==null )    return;
  1977.  
  1978.             var file=PersonasWindow.getChromeFile(filename);
  1979.                     
  1980.                 
  1981.             var ios = Components.classes["@mozilla.org/network/io-service;1"]
  1982.                                 .getService(Components.interfaces.nsIIOService);
  1983.             var URL = ios.newFileURI(file);
  1984.             
  1985.  
  1986.             return URL.spec;
  1987.         
  1988.         },
  1989.                 
  1990.         addClass:function(domnode, passedclass){
  1991.         
  1992.             if (!PersonasWindow.hasClass(domnode, passedclass)){
  1993.                 
  1994.                 if (domnode.className==""){domnode.className = passedclass;}
  1995.                 else{domnode.className+=" "+passedclass;}
  1996.                 
  1997.             }
  1998.         },
  1999.  
  2000.         ondoubleclick:function (event) {
  2001.         
  2002.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  2003.             
  2004.             var intendednode=PersonasWindow.hasClass(event.target,"serdo") ? event.target.previousSibling : event.target;
  2005.                     
  2006.             PersonasWindow.showitem(intendednode);
  2007.  
  2008.             event.stopPropagation();
  2009.             
  2010.         },    
  2011.  
  2012.         newsondoubleclick:function(node){
  2013.  
  2014.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  2015.             
  2016.             var intendednode=PersonasWindow.hasClass(node,"serdo") ? node.previousSibling.previousSibling : node;
  2017.             
  2018.             var siteuri=intendednode.siteuri;
  2019.                 
  2020.             if (window.opener!=undefined && window.opener.gBrowser!=undefined){
  2021.  
  2022.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab(siteuri);
  2023.                 window.opener.focus();
  2024.             
  2025.             }
  2026.             
  2027.             else {
  2028.                 
  2029.                 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  2030.                                    .getService(Components.interfaces.nsIWindowMediator);
  2031.                 var enumerator = wm.getEnumerator("navigator:browser");
  2032.                 
  2033.                 var win=null;
  2034.                 
  2035.                 while(enumerator.hasMoreElements()) {
  2036.  
  2037.                     win = enumerator.getNext();
  2038.  
  2039.                     break;
  2040.  
  2041.                 }
  2042.                 
  2043.                 if (win!=null){
  2044.  
  2045.                     win.gBrowser.selectedTab = win.gBrowser.addTab(siteuri);
  2046.                     win.focus();
  2047.                 
  2048.                 }
  2049.                 
  2050.                 else {
  2051.                 
  2052.                     PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("noBrowserWindowWarning"));
  2053.                 
  2054.                 }
  2055.         
  2056.             }
  2057.  
  2058.         },    
  2059.             
  2060.         showitem:function (node) {
  2061.  
  2062.             node=PersonasWindow.hasClass(node,"serdo") ? node.previousSibling : node;
  2063.             
  2064.             if(PersonasWindow.hasClass(node,"newsimage")) {PersonasWindow.newsondoubleclick(node);return;}
  2065.             
  2066.             var chosenthumbfilename=node.getAttribute("filename");
  2067.             
  2068.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  2069.             
  2070.             if (window.opener!=undefined && window.opener.PersonasRotator!=undefined){
  2071.  
  2072.                 window.opener.PersonasRotator.currentimagefilename=filename;
  2073.                 window.opener.PersonasRotator.imagespecified='yes';
  2074.                 window.opener.PersonasRotator.newimage.src=window.opener.PersonasRotator.assignFileURIToImage(filename);
  2075.                 //window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab(PersonasWindow.openTabURI);
  2076.                 //window.opener.focus();
  2077.             
  2078.                 var prefsinstance = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2079.  
  2080.                 var previewrequestalertshowable = prefsinstance.getBoolPref("extensions.personasrotator.previewrequestalertshowable");
  2081.  
  2082.                 if (previewrequestalertshowable) {
  2083.  
  2084.                     check = {value: false};
  2085.  
  2086.                     var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  2087.                                             
  2088.                     prompt.alertCheck(null,"Personas Rotator",PersonasWindow.STRINGS.getString("previewRequestAlertWarning"),PersonasWindow.STRINGS.getString("dontShowAgain"),check);
  2089.  
  2090.                     if(check.value){
  2091.  
  2092.                         prefsinstance.setBoolPref("extensions.personasrotator.previewrequestalertshowable", false);
  2093.  
  2094.                     }                
  2095.                     
  2096.                 }    
  2097.                                 
  2098.                 var previewRequestObject={filename:filename}
  2099.                 window.opener.PersonasRotator.previewThePersonaOnDesktop(previewRequestObject);
  2100.             
  2101.             }
  2102.             
  2103.             else {
  2104.                 
  2105.                 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  2106.                                    .getService(Components.interfaces.nsIWindowMediator);
  2107.                 var enumerator = wm.getEnumerator("navigator:browser");
  2108.                 
  2109.                 var win=null;
  2110.                 
  2111.                 while(enumerator.hasMoreElements()) {
  2112.  
  2113.                     win = enumerator.getNext();
  2114.  
  2115.                     break;
  2116.  
  2117.                 }
  2118.                 
  2119.                 if (win!=null){
  2120.  
  2121.                     win.PersonasRotator.currentimagefilename=filename;
  2122.                         
  2123.                     win.PersonasRotator.imagespecified='yes';
  2124.                     win.PersonasRotator.newimage.src=node.getAttribute("src");
  2125.                     //win.gBrowser.selectedTab = win.gBrowser.addTab(PersonasWindow.openTabURI);
  2126.                     //win.focus();
  2127.             
  2128.                     var prefsinstance = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2129.  
  2130.                     var previewrequestalertshowable = prefsinstance.getBoolPref("extensions.personasrotator.previewrequestalertshowable");
  2131.  
  2132.                     if (previewrequestalertshowable) {
  2133.  
  2134.                         check = {value: false};
  2135.  
  2136.                         var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  2137.                                                 
  2138.                         prompt.alertCheck(null,"Personas Rotator",PersonasWindow.STRINGS.getString("previewRequestAlertWarning"),PersonasWindow.STRINGS.getString("dontShowAgain"),check);
  2139.  
  2140.                         if(check.value){
  2141.  
  2142.                             prefsinstance.setBoolPref("extensions.personasrotator.previewrequestalertshowable", false);
  2143.  
  2144.                         }                
  2145.                         
  2146.                     }
  2147.  
  2148.                     var previewRequestObject={filename:filename}
  2149.                 
  2150.                     win.opener.PersonasRotator.previewThePersonaOnDesktop(previewRequestObject);
  2151.                 
  2152.                 }
  2153.                 
  2154.                 else {
  2155.                 
  2156.                     PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("noBrowserWindowWarning"));
  2157.                 
  2158.                 }
  2159.         
  2160.             }
  2161.  
  2162.         },        
  2163.             
  2164.         uploaditem:function (node) {
  2165.  
  2166.             node=PersonasWindow.hasClass(node,"serdo") ? node.previousSibling : node;
  2167.             
  2168.             if(PersonasWindow.hasClass(node,"newsimage")) {PersonasWindow.newsondoubleclick(node);return;}
  2169.             
  2170.             var chosenthumbfilename=node.getAttribute("filename");
  2171.             
  2172.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  2173.             
  2174.             if (window.opener!=undefined && window.opener.PersonasRotator!=undefined){
  2175.  
  2176.                 window.opener.PersonasRotator.currentimagefilename=filename;
  2177.                 window.opener.PersonasRotator.imagespecified='yes';
  2178.                 window.opener.PersonasRotator.uploadrequested='yes';
  2179.                 window.opener.PersonasRotator.newimage.src=node.getAttribute("src");
  2180.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab(PersonasWindow.openTabURI);
  2181.                 window.opener.focus();
  2182.             
  2183.             }
  2184.             
  2185.             else {
  2186.                 
  2187.                 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  2188.                                    .getService(Components.interfaces.nsIWindowMediator);
  2189.                 var enumerator = wm.getEnumerator("navigator:browser");
  2190.                 
  2191.                 var win=null;
  2192.                 
  2193.                 while(enumerator.hasMoreElements()) {
  2194.  
  2195.                     win = enumerator.getNext();
  2196.  
  2197.                     break;
  2198.  
  2199.                 }
  2200.                 
  2201.                 if (win!=null){
  2202.  
  2203.                     win.PersonasRotator.currentimagefilename=filename;
  2204.                     win.PersonasRotator.imagespecified='yes';
  2205.                     win.PersonasRotator.uploadrequested='yes';                    
  2206.                     win.PersonasRotator.newimage.src=node.getAttribute("src");
  2207.                     win.gBrowser.selectedTab = win.gBrowser.addTab(PersonasWindow.openTabURI);
  2208.                     win.focus();
  2209.                 
  2210.                 }
  2211.                 
  2212.                 else {
  2213.                 
  2214.                     PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("noBrowserWindowWarning"));
  2215.                 
  2216.                 }
  2217.         
  2218.             }
  2219.  
  2220.         },        
  2221.         
  2222.         pasteTheCopiedImages:function (origin) {
  2223.  
  2224.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  2225.             
  2226.             if (0==PersonaWindowSelectManager.highlighteds.length) return;
  2227.             
  2228.             PersonasWindow.copypasteprocessingstate=true;
  2229.             
  2230.             if(origin=="button"){
  2231.             
  2232.                 var collectioname=PersonasWindow.retrieveButtonName(document.popupNode);
  2233.             
  2234.             }
  2235.             
  2236.             else {
  2237.             
  2238.                 var collectioname=decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,""));
  2239.         
  2240.             }
  2241.             
  2242.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++) {
  2243.             
  2244.                 var node=PersonaWindowSelectManager.highlighteds[i];
  2245.                         
  2246.                 var toBeCopiedThumbfilename=node.getAttribute("filename");
  2247.                 
  2248.                 var toBeCopiedPersonaImagefilename=PersonasWindow.createPersonaImageNameFromThumbImageName(toBeCopiedThumbfilename);
  2249.  
  2250.                 var destinationFilenameToSaveTheCopyImage=collectioname+"/"+"Personas"+"/"+PersonasWindow.getTheLeafNameFromFileNameString(toBeCopiedPersonaImagefilename);
  2251.             
  2252.                 var destinationFilenameToSaveTheCopyImage=PersonasWindow.checkNameCollison(destinationFilenameToSaveTheCopyImage);
  2253.                 
  2254.                 PersonasWindow.copyThePersonaImageForPasteCommand(toBeCopiedPersonaImagefilename,destinationFilenameToSaveTheCopyImage);
  2255.  
  2256.                 var destinationThumbImagefileame=collectioname+"/"+"Thumbs/Thumb_"+PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCopyImage);
  2257.             
  2258.                 PersonasWindow.copyTheThumbImageForPasteCommand(toBeCopiedPersonaImagefilename,destinationThumbImagefileame);
  2259.     
  2260.                 PersonasWindow.copyTheRDFForPasteCommand(toBeCopiedPersonaImagefilename,destinationFilenameToSaveTheCopyImage,"copy");
  2261.                 
  2262.                     var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  2263.      
  2264.                     var copynode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(toBeCopiedPersonaImagefilename));
  2265.                 
  2266.                     var imageResource=copynode;
  2267.                     
  2268.                     var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  2269.                     var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  2270.                     if (imagenametarget) {
  2271.                         var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2272.                     }        
  2273.                 
  2274.                     var imagedefaultPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#default");
  2275.                     var imagedefaulttarget=ds.GetTarget(imageResource,imagedefaultPredicate,true);
  2276.                     if (imagedefaulttarget) {
  2277.                         var imagedefault = imagedefaulttarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2278.                     }        
  2279.                 
  2280.                     var imagelocation = PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCopyImage);
  2281.                     
  2282.                     var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  2283.                     var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  2284.                     if (imagedescriptiontarget) {
  2285.                         var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2286.                     }        
  2287.                 
  2288.                     var imagepositionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  2289.                     var imagepositiontarget=ds.GetTarget(imageResource,imagepositionPredicate,true);
  2290.                     if (imagepositiontarget) {
  2291.                         var imageposition = imagepositiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2292.                     }        
  2293.                     
  2294.                     var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  2295.                     var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  2296.                     if (imagetagstarget) {
  2297.                         var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2298.                     }        
  2299.                 
  2300.                     var imageversionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#version");
  2301.                     var imageversiontarget=ds.GetTarget(imageResource,imageversionPredicate,true);
  2302.                     if (imageversiontarget) {
  2303.                         var imageversion = imageversiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2304.                     }        
  2305.                     
  2306.                     var imageuploadedPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#uploaded");
  2307.                     var imageuploadedtarget=ds.GetTarget(imageResource,imageuploadedPredicate,true);
  2308.                     if (imageuploadedtarget) {
  2309.                         var imageuploaded = imageuploadedtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2310.                     }        
  2311.                     
  2312.                     var imagesiteURIPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#siteuri");
  2313.                     var imagesiteURItarget=ds.GetTarget(imageResource,imagesiteURIPredicate,true);
  2314.                     if (imagesiteURItarget) {
  2315.                         var imagesiteURI = imagesiteURItarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2316.                     }        
  2317.                     
  2318.                     var imagesourcePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#source");
  2319.                     var imagesourcetarget=ds.GetTarget(imageResource,imagesourcePredicate,true);
  2320.                     if (imagesourcetarget) {
  2321.                         var imagesource = imagesourcetarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2322.                     }        
  2323.  
  2324.                     var imagescreenResPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#screenres");
  2325.                     var imagescreenRestarget=ds.GetTarget(imageResource,imagescreenResPredicate,true);
  2326.                     if (imagescreenRestarget) {
  2327.                         var imagescreenRes = imagescreenRestarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2328.                     }        
  2329.  
  2330.                     var imagebackgroundColorPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#backgroundcolor");
  2331.                     var imagebackgroundColortarget=ds.GetTarget(imageResource,imagebackgroundColorPredicate,true);
  2332.                     if (imagebackgroundColortarget) {
  2333.                         var imagebackgroundColor = imagebackgroundColortarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2334.                     }        
  2335.  
  2336.                     var newnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(destinationFilenameToSaveTheCopyImage));
  2337.                     
  2338.                     imagetags=PersonasWindow.returnCopyTagString(imagetags,destinationFilenameToSaveTheCopyImage.split("/")[0]);     
  2339.                     
  2340.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  2341.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedefault ),true);
  2342.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  2343.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  2344.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  2345.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral(imagetags ),true);
  2346.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  2347.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  2348.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  2349.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  2350.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);            
  2351.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral( imagebackgroundColor),true);            
  2352.                     
  2353.                     var mainSeq=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(collectioname)+"backs"));
  2354.  
  2355.                     mainSeq.AppendElement(newnode);
  2356.  
  2357.                     ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();    
  2358.                     
  2359.                     var dsx=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(destinationFilenameToSaveTheCopyImage)));
  2360.      
  2361.                     var newnode2=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+destinationFilenameToSaveTheCopyImage);
  2362.  
  2363.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  2364.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedefault ),true);
  2365.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  2366.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  2367.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  2368.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral( imagetags ),true);
  2369.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  2370.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  2371.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  2372.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  2373.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);
  2374.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral( imagebackgroundColor),true);
  2375.                     
  2376.                     var mainSeq2=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(dsx,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(collectioname)+"backs"));
  2377.  
  2378.                     mainSeq2.AppendElement(newnode2);
  2379.  
  2380.                     dsx.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  2381.  
  2382.                     if(origin=="button") {
  2383.                 
  2384.                     if (document.popupNode.getAttribute("clicked")=="true") {
  2385.                         
  2386.                         var chosenbuttonname=document.popupNode.getAttribute("id").replace(/button$/,"");
  2387.  
  2388.                         var relatedhtmldiv=document.getElementById(chosenbuttonname+"htmldiv");
  2389.  
  2390.                         var smallimagewrapperdiv = PersonaWindowSelectManager.highlighteds[i].parentNode; 
  2391.                         var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  2392.                         var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  2393.                         
  2394.                         PersonasWindow.removeClass(imagenode,"highlighted");
  2395.                         imagenode.setAttribute("filename",destinationThumbImagefileame);
  2396.                         imagenode.setAttribute("src",PersonasWindow.assignFileURIToImage(destinationThumbImagefileame));
  2397.                         imagenode.setAttribute("tooltiptext",imagename);
  2398.                                         
  2399.                         if(document.popupNode.hasAttribute("fillspaceleft")) {
  2400.                         
  2401.                             if(PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){                            
  2402.                                 
  2403.                                 PersonasWindow.fillspacebackuparray.push(smallimagewrapperdivclone);
  2404.                                 
  2405.                             }
  2406.                             
  2407.                         }
  2408.                         
  2409.                         else {
  2410.                             
  2411.                             if(PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){                            
  2412.                                 
  2413.                                 PersonasWindow.fillspacebackuparray.push(smallimagewrapperdivclone);
  2414.                                 
  2415.                             }
  2416.                                             
  2417.                             else if(!PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2418.                                 
  2419.                                 relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2420.                                 
  2421.                             }                            
  2422.                                                                     
  2423.                             else if(PersonasWindow.fillspacestate && !PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2424.                                 
  2425.                                 relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2426.                                 
  2427.                             }                            
  2428.                                                                                     
  2429.                             else if(!PersonasWindow.fillspacestate && !PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2430.                                 
  2431.                                 relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2432.                                 
  2433.                             }                            
  2434.                             
  2435.                         }
  2436.                         
  2437.                     }
  2438.                     
  2439.                 }
  2440.                 
  2441.                 else {
  2442.                     
  2443.                         var relatedhtmldiv=document.getElementById(encodeURI(collectioname)+"htmldiv");
  2444.  
  2445.                         var smallimagewrapperdiv = PersonaWindowSelectManager.highlighteds[i].parentNode; 
  2446.                         var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  2447.                         var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  2448.                         PersonasWindow.removeClass(imagenode,"highlighted");
  2449.                         imagenode.setAttribute("filename",destinationThumbImagefileame);
  2450.                         imagenode.setAttribute("src",PersonasWindow.assignFileURIToImage(destinationThumbImagefileame));
  2451.                         imagenode.setAttribute("tooltiptext",imagename);
  2452.                         relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2453.                         
  2454.                         var aScrollboxElement = document.getElementById('personapools');
  2455.                         var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  2456.                     
  2457.                 }
  2458.                 
  2459.             }
  2460.             
  2461.             var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  2462.                                .getService(Components.interfaces.nsIWindowMediator);
  2463.             var enumerator = wm.getEnumerator("navigator:browser");
  2464.             
  2465.             var windows=[];
  2466.         
  2467.             while(enumerator.hasMoreElements()) {
  2468.  
  2469.                 win = enumerator.getNext();
  2470.                 windows.push(win);
  2471.  
  2472.             }
  2473.         
  2474.             if (windows.length!=0){
  2475.  
  2476.                 windows[0].PersonasRotator.personaimagesarraymaker();
  2477.             
  2478.             }
  2479.         
  2480.             else {
  2481.             
  2482.             //do nothing
  2483.             
  2484.             }
  2485.         
  2486.             for (var i=0;i<windows.length;i++) {
  2487.             
  2488.                 if (i==0) continue;
  2489.  
  2490.                     windows[i].PersonasRotator.personasrotator=windows[0].PersonasRotator.personasrotator;
  2491.             
  2492.             }
  2493.                     
  2494.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++){
  2495.             
  2496.                 PersonasWindow.removeClass(PersonaWindowSelectManager.highlighteds[i],"highlighted");
  2497.             
  2498.             } 
  2499.             
  2500.             PersonaWindowSelectManager.highlighteds=[];
  2501.             PersonasWindow.copystate=false;
  2502.             PersonasWindow.updateModeOn=false;
  2503.             PersonasWindow.copypasteprocessingstate=false;
  2504.         
  2505.         },
  2506.         
  2507.         retrieveButtonName:function(node){
  2508.  
  2509.             return decodeURI(node.getAttribute("id").replace(/button$/,""));
  2510.  
  2511.         },    
  2512.         
  2513.         copyThePersonaImageForPasteCommand:function (toBeCopiedPersonaImagefilename,destinationPersonaImagefilename) {
  2514.             
  2515.             var fileToCopy=PersonasWindow.getChromeFile(toBeCopiedPersonaImagefilename);
  2516.             
  2517.             var destinationDirectroyToCopyImageIn=PersonasWindow.getAppropriateCollectionDirectoryFromFileName(destinationPersonaImagefilename);
  2518.             
  2519.             fileToCopy.copyTo(destinationDirectroyToCopyImageIn,PersonasWindow.getTheLeafNameFromFileNameString(destinationPersonaImagefilename));
  2520.         
  2521.         },    
  2522.         
  2523.         copyTheThumbImageForPasteCommand:function(toBeCopiedPersonaImagefilename,destinationThumbImagefilename) {
  2524.             
  2525.             var thumbImageToBeCopied=PersonasWindow.getThumbFile(toBeCopiedPersonaImagefilename);
  2526.             
  2527.             var destinationDirectroyToCopyThumbImageIn=PersonasWindow.getAppropriateCollectionDirectoryFromFileName(destinationThumbImagefilename);
  2528.             
  2529.             thumbImageToBeCopied.copyTo(destinationDirectroyToCopyThumbImageIn,PersonasWindow.getTheLeafNameFromFileNameString(destinationThumbImagefilename));
  2530.  
  2531.         },
  2532.  
  2533.         changeFileExtension:function(filename,extension){
  2534.  
  2535.             var array=filename.split(".");
  2536.  
  2537.             var imageextension=array[array.length-1];
  2538.  
  2539.             return filename.replace("."+imageextension,"."+extension)
  2540.  
  2541.         },    
  2542.         
  2543.         copyTheRDFForPasteCommand:function(toBeCopiedPersonaImagefilename,destinationFilenameToSaveTheCopyOrCutImage,copyorcut) {
  2544.         
  2545.         var destinationRDFImagefilename=destinationFilenameToSaveTheCopyOrCutImage.split("/")[0]+"/"+"RDFs/"+PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCopyOrCutImage)+".rdf";
  2546.         
  2547.         var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  2548.  
  2549.         var copynode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(toBeCopiedPersonaImagefilename));
  2550.     
  2551.         var imageResource=copynode;
  2552.         
  2553.         var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  2554.         var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  2555.         if (imagenametarget) {
  2556.             var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2557.         }        
  2558.             
  2559.         
  2560.         var imagedefaultPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#default");
  2561.         var imagedefaulttarget=ds.GetTarget(imageResource,imagedefaultPredicate,true);
  2562.         if (imagedefaulttarget) {
  2563.             var imagedefault = imagedefaulttarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2564.         }        
  2565.     
  2566.         
  2567.         var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  2568.         var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  2569.         if (imagedescriptiontarget) {
  2570.             var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2571.         }        
  2572.         
  2573.         var imagepositionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  2574.         var imagepositiontarget=ds.GetTarget(imageResource,imagepositionPredicate,true);
  2575.         if (imagepositiontarget) {
  2576.             var imageposition = imagepositiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2577.         }        
  2578.         
  2579.         var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  2580.         var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  2581.         if (imagetagstarget) {
  2582.             var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2583.         }        
  2584.     
  2585.         var imageversionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#version");
  2586.         var imageversiontarget=ds.GetTarget(imageResource,imageversionPredicate,true);
  2587.         if (imageversiontarget) {
  2588.             var imageversion = imageversiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2589.         }        
  2590.         
  2591.         var imageuploadedPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#uploaded");
  2592.         var imageuploadedtarget=ds.GetTarget(imageResource,imageuploadedPredicate,true);
  2593.         if (imageuploadedtarget) {
  2594.             var imageuploaded = imageuploadedtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2595.         }        
  2596.     
  2597.         var imagesiteURIPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#siteuri");
  2598.         var imagesiteURItarget=ds.GetTarget(imageResource,imagesiteURIPredicate,true);
  2599.         if (imagesiteURItarget) {
  2600.             var imagesiteURI = imagesiteURItarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2601.         }        
  2602.     
  2603.         var imagesourcePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#source");
  2604.         var imagesourcetarget=ds.GetTarget(imageResource,imagesourcePredicate,true);
  2605.         if (imagesourcetarget) {
  2606.             var imagesource = imagesourcetarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2607.         }        
  2608.         
  2609.         var imagescreenResPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#screenres");
  2610.         var imagescreenRestarget=ds.GetTarget(imageResource,imagescreenResPredicate,true);
  2611.         if (imagescreenRestarget) {
  2612.             var imagescreenRes = imagescreenRestarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2613.         }        
  2614.         
  2615.         var imagebackgroundColorPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#backgroundcolor");
  2616.         var imagebackgroundColortarget=ds.GetTarget(imageResource,imagebackgroundColorPredicate,true);
  2617.         if (imagebackgroundColortarget) {
  2618.             var imagebackgroundColor = imagebackgroundColortarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2619.         }        
  2620.             
  2621.         var nameForImage = imagename.replace(/&/g,"&");
  2622.         var locationForImage =PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCopyOrCutImage).replace(/&/g,"&");
  2623.         var descriptionForImage = imagedescription.replace(/&/g,"&");
  2624.         var positionForImage = imageposition.replace(/&/g,"&");    
  2625.         var defaultForImage = imagedefault.replace(/&/g,"&");    
  2626.         var tagsForImage = (copyorcut=="copy") ? PersonasWindow.returnCopyTagString(imagetags,destinationFilenameToSaveTheCopyOrCutImage.split("/")[0]).replace(/&/g,"&") : PersonasWindow.returnCutTagString(imagetags,toBeCopiedPersonaImagefilename.split("/")[0],destinationRDFImagefilename.split("/")[0]).replace(/&/g,"&");
  2627.         var versionForImage = imageversion.replace(/&/g,"&");
  2628.         var uploadedForImage = imageuploaded.replace(/&/g,"&");
  2629.         var siteURIForImage = imagesiteURI.replace(/&/g,"&");
  2630.         var sourceForImage = imagesource.replace(/&/g,"&");
  2631.         var screenResForImage = imagescreenRes.replace(/&/g,"&");        
  2632.         var backgroundColorForImage = imagebackgroundColor.replace(/&/g,"&");        
  2633.  
  2634.         var RDFstring='<?xml version="1.0"?>'+'<RDF:RDF xmlns:personasrotator="urn:personasrotator#" xmlns:NC="http://home.netscape.com/NC-rdf#" xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">'+
  2635.         
  2636.         '<RDF:Description  RDF:about="'+(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(destinationFilenameToSaveTheCopyOrCutImage)).replace(/&/g,"&")+'">'+
  2637.         
  2638.         '<personasrotator:name>'+nameForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:name>'+
  2639.         '<personasrotator:location>'+locationForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:location>'+
  2640.         '<personasrotator:description>'+descriptionForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:description>'+
  2641.         '<personasrotator:position>'+positionForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:position>'+
  2642.         '<personasrotator:default>'+defaultForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:default>'+
  2643.         '<personasrotator:tags>'+tagsForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:tags>'+
  2644.         '<personasrotator:version>'+versionForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:version>'+
  2645.         '<personasrotator:uploaded>'+uploadedForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:uploaded>'+
  2646.         '<personasrotator:siteuri>'+siteURIForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:siteuri>'+
  2647.         '<personasrotator:source>'+sourceForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:source>'+
  2648.         '<personasrotator:screenres>'+screenResForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:screenres>'+
  2649.         '<personasrotator:backgroundcolor>'+backgroundColorForImage.replace(/>/g,">").replace(/</g,"<")+'</personasrotator:backgroundcolor>'+
  2650.         
  2651.         '</RDF:Description></RDF:RDF>';
  2652.     
  2653.         var emptyRDFnsiFile=PersonasWindow.getChromeFile(destinationRDFImagefilename);
  2654.  
  2655.         PersonasRotatorFileIO.write(emptyRDFnsiFile,RDFstring,"w","UTF-8");
  2656.  
  2657.         },
  2658.         
  2659.         alreadyInTags: function(passedimagetags,passedcollename) {
  2660.             
  2661.             var tagsArray=passedimagetags.split(",");
  2662.             
  2663.             var tag;
  2664.             
  2665.             for (var i=0;i<tagsArray.length;i++) {
  2666.                 
  2667.                 tag=tagsArray[i];
  2668.                 
  2669.                 if(tag.replace(/^\s+|\s+$/g, '')=="") continue;
  2670.                                         
  2671.                 if(tag.toLowerCase()==passedcollename.toLowerCase()) {
  2672.                     
  2673.                     return true;
  2674.                     
  2675.                 }
  2676.                 
  2677.             }
  2678.             
  2679.             return false;
  2680.             
  2681.         },
  2682.         
  2683.         returnCopyTagString:function(passedimagetags,passedcollename){    
  2684.  
  2685.             if(PersonasWindow.alreadyInTags(passedimagetags,passedcollename)) return passedimagetags; 
  2686.             else return (passedimagetags+","+passedcollename);
  2687.         
  2688.         },
  2689.         
  2690.         returnCutTagString:function(passedimagetags,passedToBeCutCollename,destinationCollename){
  2691.             
  2692.             if(PersonasWindow.alreadyInTags(passedimagetags,destinationCollename)) {
  2693.             
  2694.             var tagsArray=passedimagetags.split(",");
  2695.             
  2696.             var textLiteral="";
  2697.             
  2698.             var tag;
  2699.             
  2700.             for (var i=0;i<tagsArray.length;i++) {
  2701.                 
  2702.                 tag=tagsArray[i];
  2703.                 
  2704.                 if(tag.replace(/^\s+|\s+$/g,'')=="") continue;
  2705.                                         
  2706.                 if(tag.toLowerCase()==passedToBeCutCollename.toLowerCase()) {
  2707.                 
  2708.                     if(i==tagsArray.length-1) {textLiteral=textLiteral.replace(/,$/,"");}
  2709.                 
  2710.                     continue;
  2711.                     
  2712.                 }
  2713.                 
  2714.                 textLiteral+=tag+(i!=tagsArray.length-1 ? "," : "");
  2715.                                 
  2716.             }
  2717.             
  2718.             return textLiteral;        
  2719.                 
  2720.             }
  2721.             
  2722.             else { 
  2723.             
  2724.             passedimagetags=destinationCollename+","+passedimagetags;
  2725.             
  2726.             var tagsArray=passedimagetags.split(",");
  2727.             
  2728.             var textLiteral="";
  2729.             
  2730.             var tag;
  2731.             
  2732.             for (var i=0;i<tagsArray.length;i++) {
  2733.                 
  2734.                 tag=tagsArray[i];
  2735.                 
  2736.                 if(tag.replace(/^\s+|\s+$/g,'')=="") continue;
  2737.                                         
  2738.                 if(tag.toLowerCase()==passedToBeCutCollename.toLowerCase()) {
  2739.                 
  2740.                     if(i==tagsArray.length-1) {textLiteral=textLiteral.replace(/,$/,"");}
  2741.                 
  2742.                     continue;
  2743.                     
  2744.                 }
  2745.                 
  2746.                 textLiteral+=tag+(i!=tagsArray.length-1 ? "," : "");
  2747.                                 
  2748.             }
  2749.             
  2750.             return textLiteral;    
  2751.             
  2752.             }
  2753.             
  2754.         },
  2755.             
  2756.         pasteTheCutImages:function (origin) {
  2757.             
  2758.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  2759.             
  2760.             if (0==PersonaWindowSelectManager.highlighteds.length) return;
  2761.  
  2762.             PersonasWindow.cutpasteprocessingstate=true;
  2763.             
  2764.             if(origin=="button"){
  2765.             
  2766.                 var collectioname=PersonasWindow.retrieveButtonName(document.popupNode);
  2767.             
  2768.             }
  2769.             
  2770.             else {
  2771.             
  2772.                 var collectioname=decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,""));
  2773.             
  2774.             }
  2775.             
  2776.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++) {
  2777.                 
  2778.                     var node=PersonaWindowSelectManager.highlighteds[i];
  2779.                             
  2780.                     var toBeCutThumbfilename=node.getAttribute("filename");
  2781.                     
  2782.                     var toBeCutPersonaImagefilename=PersonasWindow.createPersonaImageNameFromThumbImageName(toBeCutThumbfilename);
  2783.                     
  2784.                     var destinationFilenameToSaveTheCutImage=collectioname+"/"+"Personas"+"/"+PersonasWindow.getTheLeafNameFromFileNameString(toBeCutPersonaImagefilename);
  2785.  
  2786.                     var destinationFilenameToSaveTheCutImage=PersonasWindow.checkNameCollison(destinationFilenameToSaveTheCutImage);
  2787.                     
  2788.                     PersonasWindow.cutThePersonaImageForPasteCommand(toBeCutPersonaImagefilename,destinationFilenameToSaveTheCutImage);
  2789.                     
  2790.                     var destinationThumbImagefileame=collectioname+"/"+"Thumbs/Thumb_"+PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCutImage);
  2791.                     PersonasWindow.cutTheThumbImageForPasteCommand(toBeCutPersonaImagefilename,destinationThumbImagefileame);
  2792.                 
  2793.                     PersonasWindow.copyTheRDFForPasteCommand(toBeCutPersonaImagefilename,destinationFilenameToSaveTheCutImage,"cut");
  2794.                     
  2795.                     var oldRDFnsiFile=PersonasWindow.getChromeFile(PersonasWindow.createIndividualRDFFilename(toBeCutPersonaImagefilename));                
  2796.                     oldRDFnsiFile.remove(false);
  2797.                     
  2798.                     var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());
  2799.      
  2800.                     var cutnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(toBeCutPersonaImagefilename));
  2801.                 
  2802.                     var imageResource=cutnode;
  2803.                     
  2804.                     var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  2805.                     var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  2806.                     if (imagenametarget) {
  2807.                         var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2808.                     }        
  2809.                     
  2810.                     var imagedefaultPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#default");
  2811.                     var imagedefaulttarget=ds.GetTarget(imageResource,imagedefaultPredicate,true);
  2812.                     if (imagedefaulttarget) {
  2813.                         var imagedefault = imagedefaulttarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2814.                     }        
  2815.                     
  2816.                     var imagelocation = PersonasWindow.getTheLeafNameFromFileNameString(destinationFilenameToSaveTheCutImage);
  2817.                     
  2818.                     var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  2819.                     var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  2820.                     if (imagedescriptiontarget) {
  2821.                         var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2822.                     }        
  2823.                 
  2824.                     var imagepositionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  2825.                     var imagepositiontarget=ds.GetTarget(imageResource,imagepositionPredicate,true);
  2826.                     if (imagepositiontarget) {
  2827.                         var imageposition = imagepositiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2828.                     }        
  2829.                     
  2830.                     var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  2831.                     var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  2832.                     if (imagetagstarget) {
  2833.                         var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2834.                     }        
  2835.                     
  2836.                     var imageversionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#version");
  2837.                     var imageversiontarget=ds.GetTarget(imageResource,imageversionPredicate,true);
  2838.                     if (imageversiontarget) {
  2839.                         var imageversion = imageversiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2840.                     }        
  2841.                     
  2842.                     var imageuploadedPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#uploaded");
  2843.                     var imageuploadedtarget=ds.GetTarget(imageResource,imageuploadedPredicate,true);
  2844.                     if (imageuploadedtarget) {
  2845.                         var imageuploaded = imageuploadedtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2846.                     }        
  2847.                 
  2848.                     var imagesiteURIPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#siteuri");
  2849.                     var imagesiteURItarget=ds.GetTarget(imageResource,imagesiteURIPredicate,true);
  2850.                     if (imagesiteURItarget) {
  2851.                         var imagesiteURI = imagesiteURItarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2852.                     }        
  2853.                 
  2854.                     var imagesourcePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#source");
  2855.                     var imagesourcetarget=ds.GetTarget(imageResource,imagesourcePredicate,true);
  2856.                     if (imagesourcetarget) {
  2857.                         var imagesource = imagesourcetarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2858.                     }        
  2859.                 
  2860.                     var imagescreenResPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#screenres");
  2861.                     var imagescreenRestarget=ds.GetTarget(imageResource,imagescreenResPredicate,true);
  2862.                     if (imagescreenRestarget) {
  2863.                         var imagescreenRes = imagescreenRestarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2864.                     }        
  2865.                 
  2866.                     var imagebackgroundColorPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#backgroundcolor");
  2867.                     var imagebackgroundColortarget=ds.GetTarget(imageResource,imagebackgroundColorPredicate,true);
  2868.                     if (imagebackgroundColortarget) {
  2869.                         var imagebackgroundColor = imagebackgroundColortarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  2870.                     }        
  2871.                     
  2872.                     var newnode=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(destinationFilenameToSaveTheCutImage));
  2873.                     
  2874.                     imagetags=PersonasWindow.returnCutTagString(imagetags,toBeCutPersonaImagefilename.split("/")[0],destinationFilenameToSaveTheCutImage.split("/")[0]);
  2875.                     
  2876.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  2877.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedefault ),true);
  2878.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  2879.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  2880.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  2881.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral( imagetags ),true);
  2882.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  2883.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  2884.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  2885.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  2886.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);
  2887.                     ds.Assert(newnode,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral( backgroundColor),true);
  2888.                     
  2889.                     var mainSeq=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(collectioname)+"backs"));
  2890.  
  2891.                     mainSeq.AppendElement(newnode);
  2892.  
  2893.                     ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();            
  2894.                     
  2895.                     var dsx=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(destinationFilenameToSaveTheCutImage)));
  2896.      
  2897.                     var newnode2=PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(destinationFilenameToSaveTheCutImage));
  2898.  
  2899.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#name" ),PersonasRotatorRDF.rdfService.GetLiteral( imagename ),true);
  2900.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#default" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedefault ),true);
  2901.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#description" ),PersonasRotatorRDF.rdfService.GetLiteral( imagedescription ),true);
  2902.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#location" ),PersonasRotatorRDF.rdfService.GetLiteral( imagelocation ),true);
  2903.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#position" ),PersonasRotatorRDF.rdfService.GetLiteral( imageposition ),true);
  2904.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#tags" ),PersonasRotatorRDF.rdfService.GetLiteral( imagetags ),true);
  2905.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#version" ),PersonasRotatorRDF.rdfService.GetLiteral( imageversion),true);    
  2906.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#uploaded" ),PersonasRotatorRDF.rdfService.GetLiteral( imageuploaded),true);
  2907.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#siteuri" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesiteURI),true);
  2908.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#source" ),PersonasRotatorRDF.rdfService.GetLiteral( imagesource),true);
  2909.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#screenres" ),PersonasRotatorRDF.rdfService.GetLiteral( imagescreenRes),true);
  2910.                     dsx.Assert(newnode2,PersonasRotatorRDF.rdfService.GetResource( "urn:personasrotator#backgroundcolor" ),PersonasRotatorRDF.rdfService.GetLiteral( backgroundColor),true);
  2911.                     
  2912.                     var mainSeq2=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(dsx,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:"+PersonasWindow.createEncodedName(collectioname)+"backs"));
  2913.  
  2914.                     mainSeq2.AppendElement(newnode2);
  2915.  
  2916.                     dsx.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  2917.                     
  2918.                     var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(toBeCutPersonaImagefilename);
  2919.                     
  2920.                     var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  2921.                     
  2922.                     var rdfnode = PersonasRotatorRDF.rdfService.GetResource(uri);
  2923.                     
  2924.                     var resourceNode=rdfnode;
  2925.                 
  2926.                     PersonasWindow.removeChildren(ds,resourceNode,false);
  2927.                     
  2928.                     var predicatesIn=ds.ArcLabelsIn(resourceNode);
  2929.                     while (predicatesIn.hasMoreElements()){
  2930.                       
  2931.                         var predicateIn=predicatesIn.getNext();
  2932.                         var source=ds.GetSource(predicateIn,resourceNode,true);
  2933.                         ds.Unassert(source,predicateIn,resourceNode);
  2934.  
  2935.                     }            
  2936.                 
  2937.                     PersonasWindow.removeRelatedImageNodeFromCollectionDatabase(toBeCutPersonaImagefilename);
  2938.                     
  2939.                     PersonasWindow.removeImageFromCollectionDOMTree(node.parentNode,"cut");
  2940.                     
  2941.                     if(origin=="button") {
  2942.                         
  2943.                         if (document.popupNode.getAttribute("clicked")=="true") {
  2944.  
  2945.                             var chosenbuttonname=document.popupNode.getAttribute("id").replace(/button$/,"");
  2946.  
  2947.                             var relatedhtmldiv=document.getElementById(chosenbuttonname+"htmldiv");
  2948.                             
  2949.                             var smallimagewrapperdiv = PersonaWindowSelectManager.highlighteds[i].parentNode; 
  2950.                             var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  2951.                             var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  2952.                             PersonasWindow.removeClass(imagenode,"highlighted");
  2953.                             imagenode.setAttribute("filename",destinationThumbImagefileame);
  2954.                             imagenode.setAttribute("src",PersonasWindow.assignFileURIToImage(destinationThumbImagefileame));
  2955.                             imagenode.setAttribute("tooltiptext",imagename);
  2956.  
  2957.                             if(document.popupNode.hasAttribute("fillspaceleft")) {
  2958.                             
  2959.                                 if(PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2960.                                 
  2961.                                     PersonasWindow.fillspacebackuparray.push(smallimagewrapperdivclone);
  2962.                                     
  2963.                                 }
  2964.                                     
  2965.                             }
  2966.                             
  2967.                             else {
  2968.                                 
  2969.                                 if(PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2970.                                 
  2971.                                     PersonasWindow.fillspacebackuparray.push(smallimagewrapperdivclone);
  2972.                                     
  2973.                                 }
  2974.                                                 
  2975.                                 else if(!PersonasWindow.fillspacestate && PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2976.                                     
  2977.                                     relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2978.                                     
  2979.                                 }                            
  2980.                                                                         
  2981.                                 else if(PersonasWindow.fillspacestate && !PersonasWindow.hasClass(relatedhtmldiv,"active")){                                    
  2982.                                     
  2983.                                     relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2984.                                     
  2985.                                 }                            
  2986.                                                                                         
  2987.                                 else if(!PersonasWindow.fillspacestate && !PersonasWindow.hasClass(relatedhtmldiv,"active")){
  2988.                                 
  2989.                                     relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  2990.                                     
  2991.                                 }                            
  2992.                                 
  2993.                             }
  2994.                                             
  2995.                         }
  2996.                                         
  2997.                     }
  2998.                     
  2999.                     else {
  3000.                                 
  3001.                         var relatedhtmldiv=document.getElementById(encodeURI(collectioname)+"htmldiv");
  3002.                         
  3003.                         var smallimagewrapperdiv = PersonaWindowSelectManager.highlighteds[i].parentNode; 
  3004.                         var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  3005.                         var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  3006.                         PersonasWindow.removeClass(imagenode,"highlighted");
  3007.                         imagenode.setAttribute("filename",destinationThumbImagefileame);
  3008.                         imagenode.setAttribute("src",PersonasWindow.assignFileURIToImage(destinationThumbImagefileame));
  3009.                         imagenode.setAttribute("tooltiptext",imagename);
  3010.                     
  3011.                         relatedhtmldiv.appendChild(smallimagewrapperdivclone);
  3012.  
  3013.                     }
  3014.         
  3015.  
  3016.                 }
  3017.             
  3018.                 if(origin=="button") {
  3019.                     
  3020.                     var activehtmldiv=document.getElementsByClassName("active")[0];
  3021.                     var totalpersonasnumber=activehtmldiv.childNodes.length;
  3022.                     
  3023.                     if((totalpersonasnumber%3)==0) activehtmldiv.style.height=((totalpersonasnumber/3)*155)+"px";
  3024.                     if((totalpersonasnumber%3)==1) activehtmldiv.style.height=(Math.round((totalpersonasnumber/3)+0.33)*155)+"px";
  3025.                     if((totalpersonasnumber%3)==2) activehtmldiv.style.height=(Math.round((totalpersonasnumber/3))*155)+"px";
  3026.  
  3027.                 }
  3028.         
  3029.             var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  3030.                                .getService(Components.interfaces.nsIWindowMediator);
  3031.             var enumerator = wm.getEnumerator("navigator:browser");
  3032.             
  3033.             var windows=[];
  3034.             
  3035.             var win;
  3036.         
  3037.             while(enumerator.hasMoreElements()) {
  3038.  
  3039.                 win = enumerator.getNext();
  3040.                 windows.push(win);
  3041.  
  3042.             }
  3043.         
  3044.             if (windows.length!=0){
  3045.         
  3046.  
  3047.                 windows[0].PersonasRotator.personaimagesarraymaker();
  3048.             
  3049.             }
  3050.         
  3051.             else {
  3052.             
  3053.             //do nothing
  3054.             
  3055.             }        
  3056.         
  3057.             for (var i=0;i<windows.length;i++) {
  3058.             
  3059.                 if (i==0) continue;
  3060.  
  3061.                     windows[i].PersonasRotator.personasrotator=windows[0].PersonasRotator.personasrotator;
  3062.             }
  3063.                     
  3064.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++){
  3065.             
  3066.                 PersonasWindow.removeClass(PersonaWindowSelectManager.highlighteds[i],"highlighted");
  3067.             
  3068.             } 
  3069.             
  3070.             PersonaWindowSelectManager.highlighteds=[];
  3071.             PersonasWindow.cutstate=false;
  3072.             PersonasWindow.updateModeOn=false;
  3073.             PersonasWindow.cutpasteprocessingstate=false;
  3074.             
  3075.             },
  3076.         
  3077.         cutThePersonaImageForPasteCommand:function (toBeCutPersonaImagefilename,destinationPersonaImagefilename) {
  3078.             
  3079.             var fileToCut=PersonasWindow.getChromeFile(toBeCutPersonaImagefilename);
  3080.             
  3081.             var destinationDirectroyToCopyImageIn=PersonasWindow.getAppropriateCollectionDirectoryFromFileName(destinationPersonaImagefilename);
  3082.             
  3083.             fileToCut.copyTo(destinationDirectroyToCopyImageIn,PersonasWindow.getTheLeafNameFromFileNameString(destinationPersonaImagefilename));
  3084.             
  3085.             fileToCut.remove(false);
  3086.             
  3087.         },    
  3088.         
  3089.         cutTheThumbImageForPasteCommand:function(toBeCutPersonaImagefilename,destinationThumbImagefilename) {
  3090.             
  3091.             var thumbImageToBeCut=PersonasWindow.getThumbFile(toBeCutPersonaImagefilename);        
  3092.             
  3093.             var destinationDirectroyToCutThumbImageIn=PersonasWindow.getAppropriateCollectionDirectoryFromFileName(destinationThumbImagefilename);
  3094.             
  3095.             thumbImageToBeCut.copyTo(destinationDirectroyToCutThumbImageIn,PersonasWindow.getTheLeafNameFromFileNameString(destinationThumbImagefilename));
  3096.         
  3097.             thumbImageToBeCut.remove(false);
  3098.             
  3099.         },
  3100.  
  3101.         activatecopyitem:function () {
  3102.  
  3103.             if(PersonaWindowSelectManager.highlighteds.length==0) {PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getFormattedString("noSelectedItemWarning",["copy"]));return;};
  3104.  
  3105.             PersonasWindow.copystate=true;
  3106.             
  3107.             PersonasWindow.refreshOtherStates("copystate");
  3108.         
  3109.         },
  3110.         
  3111.         refreshOtherStates:function(mode){
  3112.     
  3113.             if (mode=="copystate") {PersonasWindow.copystate=true;} else {PersonasWindow.copystate=false;}
  3114.             if (mode=="cutstate") {PersonasWindow.cutstate=true;} else {PersonasWindow.cutstate=false;}
  3115.             if (mode=="deletestate") {PersonasWindow.deletestate=true;} else {PersonasWindow.deletestate=false;}
  3116.             if (mode=="editstate") {PersonasWindow.editstate=true;} else {PersonasWindow.editstate=false;}
  3117.         
  3118.         },
  3119.         
  3120.         activatecutitem:function () {
  3121.             
  3122.             if(PersonaWindowSelectManager.highlighteds.length==0) {PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getFormattedString("noSelectedItemWarning",["cut"]));return;};
  3123.  
  3124.             PersonasWindow.cutstate=true;
  3125.             PersonasWindow.refreshOtherStates("cutstate");
  3126.             
  3127.         },
  3128.  
  3129.         activatedeleteitem:function () {
  3130.  
  3131.         if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  3132.         
  3133.         if(PersonaWindowSelectManager.highlighteds.length==0) {PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getFormattedString("noSelectedItemWarning",["delete"]));return;};
  3134.         
  3135.         if(PersonasWindow.createConfirmPrompt(PersonasWindow.STRINGS.getFormattedString("deleteWarning",[(PersonaWindowSelectManager.highlighteds.length!=1 ? "All selected personas" : "Selected persona")]))) {
  3136.             
  3137.             PersonasWindow.deletestate=true;
  3138.             
  3139.             PersonasWindow.refreshOtherStates("deletestate");
  3140.             
  3141.             PersonasWindow.updateModeOn=true;
  3142.             
  3143.             if (PersonasWindow.deletestate==true) {        
  3144.  
  3145.             PersonasWindow.arrayinc=PersonaWindowSelectManager.highlighteds.length-1;
  3146.             
  3147.             PersonasWindow.deleteitemstart();
  3148.             
  3149.             }
  3150.                 
  3151.         }
  3152.                 
  3153.         },
  3154.  
  3155.         activatepasteitem:function (event) {
  3156.             
  3157.             if(PersonaWindowSelectManager.highlighteds.length==0) {PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getFormattedString("noSelectedItemWarning",["copy or cut the thumbnail. After that right click on collection button to paste."]));return;};
  3158.         
  3159.             if(PersonaWindowSelectManager.highlighteds.length>15) {
  3160.             
  3161.                 if(PersonasWindow.createConfirmPrompt(PersonasWindow.STRINGS.getString("pasteWarning"))) {return;}
  3162.             
  3163.             }
  3164.             
  3165.             if (document.popupNode.tagName!="label" && document.popupNode.tagName!="stack" && document.popupNode.tagName!="scrollbox" &&document.popupNode.tagName!="html:div") return;
  3166.             
  3167.             var origin=document.popupNode.tagName=="label" ? "button" : "stack";
  3168.             
  3169.             if (PersonasWindow.copystate==true) {
  3170.                 
  3171.                 PersonasWindow.pasteTheCopiedImages(origin);
  3172.                 
  3173.             }
  3174.                     
  3175.             if (PersonasWindow.cutstate==true) {    
  3176.                 
  3177.                 PersonasWindow.pasteTheCutImages(origin);
  3178.         
  3179.             }    
  3180.                 
  3181.         },    
  3182.             
  3183.         deleteitemstart:function(){
  3184.         
  3185.         if(PersonasWindow.arrayinc==-1) {
  3186.             
  3187.             var activehtmldiv=document.getElementsByClassName("active")[0];
  3188.             var totalpersonasnumber=activehtmldiv.childNodes.length;
  3189.             
  3190.             if((totalpersonasnumber%3)==0) activehtmldiv.style.height=((totalpersonasnumber/3)*155)+"px";
  3191.             if((totalpersonasnumber%3)==1) activehtmldiv.style.height=(Math.round((totalpersonasnumber/3)+0.33)*155)+"px";
  3192.             if((totalpersonasnumber%3)==2) activehtmldiv.style.height=(Math.round((totalpersonasnumber/3))*155)+"px";
  3193.         
  3194.             PersonasWindow.arrayinc=0;
  3195.             PersonaWindowSelectManager.highlighteds=[];return;
  3196.         
  3197.         }
  3198.         
  3199.             var itemsleft=PersonaWindowSelectManager.highlighteds.length-PersonasWindow.arrayinc;
  3200.             
  3201.                     window.setTimeout(function(){
  3202.                         var node=PersonaWindowSelectManager.highlighteds[PersonasWindow.arrayinc];
  3203.                         
  3204.                         (PersonasWindow.arrayinc!=0) ? PersonasWindow.deleteitem(node) : PersonasWindow.lastdeleteitemfunction(node,true);
  3205.                     
  3206.                     },1);
  3207.         
  3208.         },
  3209.             
  3210.         lastdeleteitemfunction:function(node,last){
  3211.  
  3212.             PersonasWindow.deleteitem(node,last);
  3213.             PersonasWindow.deletestate=false;
  3214.             PersonasWindow.arrayinc=0;
  3215.             PersonasWindow.updateModeOn=false;
  3216.         
  3217.         },        
  3218.  
  3219.         buttonpopupshow:function (event) {
  3220.             
  3221.             var nsIPopupBoxObject = Components.interfaces.nsIPopupBoxObject;
  3222.  
  3223.             event.target.popupBoxObject.setConsumeRollupEvent(nsIPopupBoxObject.ROLLUP_NO_CONSUME);
  3224.             
  3225.             if (document.popupNode.tagName!="label") return;
  3226.             
  3227.             if (PersonasWindow.copystate==true || PersonasWindow.cutstate==true ) {
  3228.  
  3229.                 document.getElementById("button-paste").removeAttribute("disabled");
  3230.  
  3231.                 if(PersonaWindowSelectManager.highlighteds[0]==undefined) {PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("thereIsNoItemSelected"));event.preventDefault();return;}
  3232.                 
  3233.                 if(PersonaWindowSelectManager.highlighteds[0].parentNode.parentNode.id.replace(/htmldiv$/,"")==document.popupNode.id.replace(/button$/,"")) document.getElementById("button-paste").setAttribute("disabled","true");
  3234.             
  3235.             }
  3236.  
  3237.             else {
  3238.  
  3239.                 document.getElementById("button-paste").setAttribute("disabled","true");
  3240.  
  3241.             }
  3242.         
  3243.             event.stopPropagation();
  3244.  
  3245.         },        
  3246.  
  3247.         xxx :function(){
  3248.         
  3249.             //obsolete method
  3250.             
  3251.         },
  3252.  
  3253.         each:function(array,func){
  3254.  
  3255.             //obsolete method
  3256.             
  3257.         },
  3258.  
  3259.         scrollfinder:function(domnode){
  3260.         
  3261.             //obsolete method
  3262.             
  3263.         },
  3264.     
  3265.         handleeditclick:function (node) {
  3266.         
  3267.             node=PersonasWindow.hasClass(node,"serdo") ? node.previousSibling : node;
  3268.             
  3269.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  3270.             
  3271.             PersonasWindow.editstate=true;
  3272.             
  3273.             PersonasWindow.refreshOtherStates("editstate");
  3274.  
  3275.             var activecollectionname=node.parentNode.parentNode.getAttribute("id").replace(/htmldiv$/,"");
  3276.                 
  3277.             var chosenthumbfilename=node.getAttribute("filename");
  3278.             
  3279.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  3280.  
  3281.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  3282.  
  3283.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  3284.             
  3285.             var imageResource = PersonasRotatorRDF.rdfService.GetResource(uri);
  3286.             
  3287.             var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  3288.             var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  3289.             if (imagenametarget) {
  3290.                 var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3291.             }                            
  3292.             
  3293.             var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  3294.             var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  3295.             if (imagetagstarget) {
  3296.                 var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3297.             }                            
  3298.         
  3299.             var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  3300.             var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  3301.             if (imagedescriptiontarget) {
  3302.                 var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3303.             }
  3304.             
  3305.             var imagelocationPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#location");
  3306.             var imagelocationtarget=ds.GetTarget(imageResource,imagelocationPredicate,true);
  3307.             if (imagelocationtarget) {
  3308.                 var imagelocation = imagelocationtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3309.             }
  3310.         
  3311.             PersonasWindow.createNewEditHTMLDiv();
  3312.             
  3313.             document.getElementsByClassName("edit-name-textbox")[0].setAttribute("value",imagename);
  3314.             
  3315.             document.getElementsByClassName("edit-tags-textbox")[0].setAttribute("value",imagetags);
  3316.             
  3317.             document.getElementsByClassName("edit-description-textbox")[0].setAttribute("value",imagedescription!="undefined" ? imagedescription : "" );
  3318.             
  3319.             PersonasWindow.addClass(document.getElementById("gallerynavbuttons"),"buttoninactive");
  3320.             
  3321.             PersonasWindow.removeClass(document.getElementById("editnavbuttons"),"buttoninactive");
  3322.  
  3323.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  3324.             
  3325.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  3326.         
  3327.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++){
  3328.             
  3329.                 PersonasWindow.removeClass(PersonaWindowSelectManager.highlighteds[i],"highlighted");
  3330.             
  3331.             }
  3332.             
  3333.             PersonaWindowSelectManager.highlighteds=[];
  3334.                         
  3335.             var currentedithtmldiv=document.getElementById("gallerystack").getElementsByClassName("edithtmldiv")[0];
  3336.             
  3337.             PersonasWindow.addClass(currentedithtmldiv,"editactive");
  3338.             
  3339.             PersonasWindow.removeClass(currentedithtmldiv,"editinactive");
  3340.  
  3341.             var smallimagewrapperdiv = node.parentNode; 
  3342.             var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  3343.             smallimagewrapperdivclone.style.marginLeft="200px";
  3344.             var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  3345.             imagenode.removeAttribute("onclick");
  3346.             imagenode.nextSibling.removeAttribute("onclick");
  3347.             imagenode.removeAttribute("ondblclick");
  3348.             imagenode.nextSibling.removeAttribute("ondblclick");
  3349.             
  3350.             PersonasWindow.addClass(imagenode,"editedimage");
  3351.             PersonasWindow.removeClass(imagenode,"highlighted");
  3352.  
  3353.             currentedithtmldiv.insertBefore(smallimagewrapperdivclone,currentedithtmldiv.childNodes[0]);
  3354.  
  3355.             PersonasWindow.returndiv=activecollectionname;
  3356.             
  3357.             var aScrollboxElement = document.getElementById('personapools');
  3358.             var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  3359.             PersonasWindow.returnscrollx = {};  PersonasWindow.returnscrolly = {};
  3360.             xpcomInterface.getPosition(PersonasWindow.returnscrollx, PersonasWindow.returnscrolly);
  3361.  
  3362.         },
  3363.         
  3364.         updatePredicates:function(database,hash,filename,doc){
  3365.  
  3366.             var ds;
  3367.             
  3368.             if(database=="Individual"){
  3369.             
  3370.             ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createIndividualRDFFilename(filename)));
  3371.         
  3372.             }
  3373.             
  3374.             if(database=="Library"){    
  3375.             
  3376.             ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  3377.             
  3378.             }    
  3379.  
  3380.             if(database=="Collection"){    
  3381.         
  3382.             ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getTheURIFromFileName(PersonasWindow.createCollectionRDfFileName(filename)));
  3383.             
  3384.             }
  3385.             
  3386.             var leafName=PersonasWindow.getTheLeafNameFromFileNameString(filename);
  3387.  
  3388.             var theImageNode = PersonasRotatorRDF.rdfService.GetResource(PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename));
  3389.             
  3390.             var updatePredicateName;
  3391.             
  3392.             for (var property in hash){
  3393.             
  3394.                 updatePredicateName=property;
  3395.                 
  3396.                 var updatePredicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#"+updatePredicateName);                
  3397.             
  3398.                 var updatetarget=ds.GetTarget(theImageNode,updatePredicate,true);
  3399.                 
  3400.                 if (updatetarget!=null) var updateTargetValue= updatetarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3401.                 else {return}                
  3402.                 
  3403.                 var newUpdateTargetValue=hash[property];
  3404.                 
  3405.                 var predicate=PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#"+updatePredicateName);
  3406.                 var oldtarget=PersonasRotatorRDF.rdfService.GetLiteral(updateTargetValue);
  3407.                 var newtarget=PersonasRotatorRDF.rdfService.GetLiteral(newUpdateTargetValue);    
  3408.                 
  3409.                 ds.Change(theImageNode,predicate,oldtarget,newtarget);
  3410.                 
  3411.             }
  3412.             
  3413.             try{
  3414.             ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();                    
  3415.             }
  3416.             catch(err){
  3417.             
  3418.             }
  3419.  
  3420.         },
  3421.  
  3422.         saveEditPersonaChangesGlobally:function(filename,editchanges,doc) {
  3423.         
  3424.             if (filename==undefined) return;
  3425.             PersonasWindow.updatePredicates("Individual",{position:editchanges.position,backgroundcolor:editchanges.backgroundcolor},filename,doc);
  3426.             PersonasWindow.updatePredicates("Collection",{position:editchanges.position,backgroundcolor:editchanges.backgroundcolor},filename,doc);
  3427.             PersonasWindow.updatePredicates("Library",{position:editchanges.position,backgroundcolor:editchanges.backgroundcolor},filename,doc);
  3428.  
  3429.         },
  3430.         
  3431.         handleeditpersonaclick:function (node) {
  3432.         
  3433.             node=PersonasWindow.hasClass(node,"serdo") ? node.previousSibling : node;
  3434.             
  3435.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  3436.             
  3437.             //PersonasWindow.editstate=true;
  3438.             
  3439.             //PersonasWindow.refreshOtherStates("editstate");
  3440.  
  3441.             var activecollectionname=node.parentNode.parentNode.getAttribute("id").replace(/htmldiv$/,"");
  3442.                 
  3443.             var chosenthumbfilename=node.getAttribute("filename");
  3444.             
  3445.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  3446.  
  3447.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  3448.  
  3449.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  3450.             
  3451.             var imageResource = PersonasRotatorRDF.rdfService.GetResource(uri);
  3452.             
  3453.             var imagenamePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
  3454.             var imagenametarget=ds.GetTarget(imageResource,imagenamePredicate,true);
  3455.             if (imagenametarget) {
  3456.                 var imagename = imagenametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3457.             }                            
  3458.             
  3459.             var imagetagsPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#tags");
  3460.             var imagetagstarget=ds.GetTarget(imageResource,imagetagsPredicate,true);
  3461.             if (imagetagstarget) {
  3462.                 var imagetags = imagetagstarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3463.             }                            
  3464.         
  3465.             var imagedescriptionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#description");
  3466.             var imagedescriptiontarget=ds.GetTarget(imageResource,imagedescriptionPredicate,true);
  3467.             if (imagedescriptiontarget) {
  3468.                 var imagedescription = imagedescriptiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3469.             }
  3470.             
  3471.             var imagelocationPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#location");
  3472.             var imagelocationtarget=ds.GetTarget(imageResource,imagelocationPredicate,true);
  3473.             if (imagelocationtarget) {
  3474.                 var imagelocation = imagelocationtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3475.             }
  3476.             
  3477.             var imagebackgroundColorPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#backgroundcolor");
  3478.             var imagebackgroundColortarget=ds.GetTarget(imageResource,imagebackgroundColorPredicate,true);
  3479.             if (imagebackgroundColortarget) {
  3480.                 var imagebackgroundColor = imagebackgroundColortarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3481.             }
  3482.                     
  3483.             var imagepositionPredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#position");
  3484.             var imagepositiontarget=ds.GetTarget(imageResource,imagepositionPredicate,true);
  3485.             if (imagepositiontarget) {
  3486.                 var imageposition = imagepositiontarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  3487.             }
  3488.         
  3489.             //PersonasWindow.createNewEditHTMLDiv();
  3490.             
  3491.             //document.getElementsByClassName("edit-name-textbox")[0].setAttribute("value",imagename);
  3492.             
  3493.             //document.getElementsByClassName("edit-tags-textbox")[0].setAttribute("value",imagetags);
  3494.             
  3495.             //document.getElementsByClassName("edit-description-textbox")[0].setAttribute("value",imagedescription!="undefined" ? imagedescription : "" );
  3496.             
  3497.             //PersonasWindow.addClass(document.getElementById("gallerynavbuttons"),"buttoninactive");
  3498.             
  3499.             //PersonasWindow.removeClass(document.getElementById("editnavbuttons"),"buttoninactive");
  3500.  
  3501.             //if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  3502.             
  3503.             //if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  3504.         
  3505.             //for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++){
  3506.             
  3507.                 //PersonasWindow.removeClass(PersonaWindowSelectManager.highlighteds[i],"highlighted");
  3508.             
  3509.             //}
  3510.             
  3511.             //PersonaWindowSelectManager.highlighteds=[];
  3512.                         
  3513.             //var currentedithtmldiv=document.getElementById("gallerystack").getElementsByClassName("edithtmldiv")[0];
  3514.             
  3515.             //PersonasWindow.addClass(currentedithtmldiv,"editactive");
  3516.             
  3517.             //PersonasWindow.removeClass(currentedithtmldiv,"editinactive");
  3518.  
  3519.             //var smallimagewrapperdiv = node.parentNode; 
  3520.             //var smallimagewrapperdivclone = smallimagewrapperdiv.cloneNode(true);
  3521.             //smallimagewrapperdivclone.style.marginLeft="200px";
  3522.             //var imagenode=smallimagewrapperdivclone.getElementsByTagName("image")[0];
  3523.             //imagenode.removeAttribute("onclick");
  3524.             //imagenode.nextSibling.removeAttribute("onclick");
  3525.             //imagenode.removeAttribute("ondblclick");
  3526.             //imagenode.nextSibling.removeAttribute("ondblclick");
  3527.             
  3528.             //PersonasWindow.addClass(imagenode,"editedimage");
  3529.             //PersonasWindow.removeClass(imagenode,"highlighted");
  3530.  
  3531.             //currentedithtmldiv.insertBefore(smallimagewrapperdivclone,currentedithtmldiv.childNodes[0]);
  3532.  
  3533.             //PersonasWindow.returndiv=activecollectionname;
  3534.             
  3535.             //var aScrollboxElement = document.getElementById('personapools');
  3536.             //var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  3537.             //PersonasWindow.returnscrollx = {};  PersonasWindow.returnscrolly = {};
  3538.             //xpcomInterface.getPosition(PersonasWindow.returnscrollx, PersonasWindow.returnscrolly);            
  3539.                 
  3540.             var personaImageToEdit=new Image();
  3541.             personaImageToEdit.src=PersonasWindow.assignFileURIToImage(filename);
  3542.             
  3543.             var PersonasRotatorOptions={collection:false,edit:true,filename:filename,position:imageposition,backgroundcolor:parseInt(imagebackgroundColor)}
  3544.             
  3545.             personaImageToEdit.onload=function(){
  3546.  
  3547.                 // On non-Mac platforms, the Set Persona dialog is modal.
  3548.                 openDialog("chrome://browser/content/setDesktopBackground.xul", "","centerscreen,chrome,dialog,modal,dependent",personaImageToEdit,PersonasRotatorOptions);
  3549.  
  3550.             }
  3551.  
  3552.         },
  3553.         
  3554.         createNewEditHTMLDiv:function() {
  3555.  
  3556.         var newedithtmldiv=document.createElementNS("http://www.w3.org/1999/xhtml","html:div");
  3557.         
  3558.         newedithtmldiv.setAttribute("class","editinactive edithtmldiv htmldiv");
  3559.         
  3560.         var appendededithtml=document.getElementById("gallerystack").appendChild(newedithtmldiv);
  3561.         
  3562.         var namelabel=document.createElement("label");
  3563.         
  3564.         namelabel.setAttribute("value","Name");    
  3565.         namelabel.setAttribute("style","display:block;clear:both;color:white;margin-top:15px;");    
  3566.         namelabel.setAttribute("class","edit-name-label");    
  3567.         
  3568.         var descriptionlabel=document.createElement("label");
  3569.         descriptionlabel.setAttribute("value","Description");
  3570.         descriptionlabel.setAttribute("style","display:block;color:white;");
  3571.         descriptionlabel.setAttribute("class","edit-description-label");
  3572.         
  3573.         var tagslabel=document.createElement("label");
  3574.         tagslabel.setAttribute("value","Tags");
  3575.         tagslabel.setAttribute("style","display:block;color:white;");
  3576.         tagslabel.setAttribute("class","edit-tags-label");
  3577.         
  3578.         var nametextbox=document.createElement("textbox");
  3579.         
  3580.         nametextbox.setAttribute("size","100");
  3581.         nametextbox.setAttribute("value","");
  3582.         nametextbox.setAttribute("oninput","document.getElementsByClassName('editedimage')[0].nextSibling.firstChild.nodeValue=this.value;");    
  3583.     
  3584.         nametextbox.setAttribute("class","edit-name-textbox");
  3585.         
  3586.         var tagstextbox=document.createElement("textbox");
  3587.         tagstextbox.setAttribute("size","100");
  3588.         tagstextbox.setAttribute("value","");
  3589.  
  3590.         tagstextbox.setAttribute("class","edit-tags-textbox");
  3591.         
  3592.         var descriptiontextbox=document.createElement("textbox");
  3593.         descriptiontextbox.setAttribute("size","100");
  3594.         descriptiontextbox.setAttribute("value","");
  3595.         descriptiontextbox.setAttribute("multiline","true");
  3596.         descriptiontextbox.setAttribute("width","525");
  3597.         descriptiontextbox.setAttribute("height","130");
  3598.  
  3599.         descriptiontextbox.setAttribute("class","edit-description-textbox");
  3600.     
  3601.         appendededithtml.appendChild(namelabel);
  3602.         appendededithtml.appendChild(nametextbox);
  3603.         appendededithtml.appendChild(tagslabel);
  3604.         appendededithtml.appendChild(tagstextbox);
  3605.         appendededithtml.appendChild(descriptionlabel);
  3606.         appendededithtml.appendChild(descriptiontextbox);
  3607.  
  3608.         },
  3609.  
  3610.         Editsave:function () {
  3611.  
  3612.             var node=document.getElementsByClassName("editedimage")[0]; 
  3613.         
  3614.             var activecollectionname=node.getAttribute("src").split(PersonasWindow.personaImagePreName)[1].split("/")[0];
  3615.  
  3616.             var chosenthumbfilename=node.getAttribute("filename");
  3617.             
  3618.             var filename=PersonasWindow.createPersonaImageNameFromThumbImageName(chosenthumbfilename);
  3619.  
  3620.             var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasWindow.getlibraryfileURI());    
  3621.  
  3622.             var uri=PersonasWindow.databaseResourceSiteName+PersonasWindow.createEncodedName(filename);
  3623.             
  3624.             var imageResource = PersonasRotatorRDF.rdfService.GetResource(uri);
  3625.  
  3626.             var newimagename=document.getElementsByClassName("edit-name-textbox")[0].value;
  3627.             var newimagedescription=document.getElementsByClassName("edit-description-textbox")[0].value;
  3628.             var newimagetags=document.getElementsByClassName("edit-tags-textbox")[0].value;
  3629.             
  3630.             PersonasWindow.updatePredicates("Individual",{name:newimagename,tags:newimagetags,description:newimagedescription},filename,null);
  3631.             PersonasWindow.updatePredicates("Collection",{name:newimagename,tags:newimagetags,description:newimagedescription},filename,null);
  3632.             PersonasWindow.updatePredicates("Library",{name:newimagename,tags:newimagetags,description:newimagedescription},filename,null);
  3633.                 
  3634.             var colname=filename.split("/")[0];
  3635.             var htmldivname=encodeURI(colname)+"htmldiv";
  3636.             var thumburi=node.getAttribute("src");
  3637.             var imagearray=document.getElementById(htmldivname).getElementsByTagName("image");
  3638.  
  3639.             var intendedimagenode={};
  3640.  
  3641.             for (var i=0;i<imagearray.length;i++) {
  3642.  
  3643.                 if(imagearray[i].getAttribute("src")==thumburi) {
  3644.  
  3645.                     imagearray[i].nextSibling.firstChild.nodeValue=newimagename;
  3646.                     imagearray[i].setAttribute("tooltiptext",newimagename);
  3647.                     intendedimagenode=imagearray[i];
  3648.                     break;
  3649.             
  3650.                 }
  3651.         
  3652.             }
  3653.         
  3654.         if(PersonasWindow.editstate==true) {
  3655.  
  3656.         document.getElementsByClassName("edithtmldiv")[0].parentNode.removeChild(document.getElementsByClassName("edithtmldiv")[0]);
  3657.         
  3658.         PersonasWindow.editstate=false;
  3659.         
  3660.         }
  3661.     
  3662.         if(!PersonasWindow.hasClass(document.getElementById("editnavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("editnavbuttons"),"buttoninactive");}
  3663.         
  3664.         if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  3665.         if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  3666.         
  3667.         PersonasWindow.removeClass(document.getElementById("gallerynavbuttons"),"buttoninactive");
  3668.         
  3669.         PersonasWindow.addClass(document.getElementById((PersonasWindow.returndiv).toString()+"htmldiv"),"active");
  3670.         PersonasWindow.removeClass(document.getElementById((PersonasWindow.returndiv).toString()+"htmldiv"),"inactive");
  3671.         
  3672.         var aScrollboxElement = document.getElementById('personapools');
  3673.         var xpcomInterface = aScrollboxElement.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
  3674.  
  3675.         window.setTimeout(function(){xpcomInterface.scrollTo(PersonasWindow.returnscrollx.value,PersonasWindow.returnscrolly.value)},1);
  3676.     
  3677.         PersonasWindow.returndiv="";
  3678.                 
  3679.         },
  3680.         
  3681.         retrieveclicknode:function (event) {
  3682.  
  3683.             if(PersonasWindow.updateModeOn==true) {return;};
  3684.             
  3685.             if(event.target.tagName=="menuitem") return;
  3686.  
  3687.             if(PersonasWindow.hasClass(event.target,"collection-button")) return;
  3688.             
  3689.             if(event.target.tagName=="image") return;
  3690.             
  3691.             if(PersonasWindow.hasClass(event.target,"serdo")) return;
  3692.                                                                                                                 
  3693.             if((PersonasWindow.hasClass(event.target,"imagewrapperdiv")||PersonasWindow.hasClass(event.target,"active")||event.target.getAttribute("id")=="personapools")) {
  3694.         
  3695.                 if (PersonasWindow.copystate==true||PersonasWindow.cutstate==true){
  3696.         
  3697.                     if(!PersonasWindow.hasClass(PersonaWindowSelectManager.highlighteds[0].parentNode.parentNode,"active")){
  3698.                     
  3699.                         return;
  3700.                     
  3701.                     }
  3702.                 }    
  3703.  
  3704.             }
  3705.  
  3706.             for (var i=0;i<PersonaWindowSelectManager.highlighteds.length;i++){
  3707.             
  3708.                 PersonasWindow.removeClass(PersonaWindowSelectManager.highlighteds[i],"highlighted");
  3709.             
  3710.             }
  3711.             
  3712.             PersonaWindowSelectManager.highlighteds=[];
  3713.             PersonasWindow.copystate=false;
  3714.             PersonasWindow.cutstate=false;
  3715.  
  3716.         },
  3717.         
  3718.         morelikethis:function(){
  3719.             
  3720.             //obsolete
  3721.             var prefix=decodeURI(document.getElementsByClassName("active")[0].getAttribute("id").replace(/htmldiv$/,""))
  3722.             
  3723.             if(window.opener!=undefined && window.opener.gBrowser!=undefined){
  3724.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab('http://personasrotator.com/persona/gallery_tag/'+encodeURIComponent(prefix));
  3725.                 window.opener.focus();
  3726.             }
  3727.             
  3728.         
  3729.         },
  3730.         
  3731.         openPersonasRotatorsite:function(){
  3732.                 
  3733.             if (window.opener!=undefined && window.opener.gBrowser!=undefined){
  3734.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab('http://personasrotator.com/index.php?extmnlg');
  3735.                 window.opener.focus();
  3736.             }
  3737.             else{PersonasWindow.createAlertPrompt(PersonasWindow.STRINGS.getString("noBrowserWindowWarning"));}
  3738.         
  3739.         },        
  3740.  
  3741.         retrieveAppropriateAlertText:function(){
  3742.         
  3743.             if(PersonasWindow.additemsstate==true) {return PersonasWindow.STRINGS.getFormattedString("stateWarning",["Adding"])}
  3744.             else if(PersonasWindow.fillspacestate==true) {return PersonasWindow.STRINGS.getFormattedString("stateWarning",["Retrieving"])}
  3745.             else if(PersonasWindow.deletestate==true) {return PersonasWindow.STRINGS.getFormattedString("stateWarning",["Deleting"])}
  3746.             else if(PersonasWindow.copypasteprocessingstate==true) {return PersonasWindow.STRINGS.getFormattedString("stateWarning",["Pasting"])}
  3747.             else if(PersonasWindow.cutpasteprocessingstate==true) {return PersonasWindow.STRINGS.getFormattedString("stateWarning",["Pasting"])}
  3748.             
  3749.         },
  3750.     
  3751.         createEncodedName:function(passedDecodedName){
  3752.         
  3753.             var namesplitarray=passedDecodedName.split("/");
  3754.             
  3755.             var encodedname="";
  3756.             
  3757.             for (var i=0;i<namesplitarray.length;i++) {
  3758.             
  3759.                 encodedname+=encodeURI(namesplitarray[i]);
  3760.                 encodedname+=(i!=namesplitarray.length-1) ? "/" : "";
  3761.         
  3762.             }
  3763.             
  3764.             return encodedname;
  3765.         
  3766.         },
  3767.         
  3768.         createDecodedName:function(passedEncodedName){
  3769.             
  3770.             var namesplitarray=passedEncodedName.split("/");
  3771.             
  3772.             var decodedname="";
  3773.             
  3774.             for (var i=0;i<namesplitarray.length;i++) {
  3775.             
  3776.             decodedname+=decodeURI(namesplitarray[i]);
  3777.             decodedname+=((i!=namesplitarray.length-1) ? "/" : "");
  3778.             
  3779.             }
  3780.     
  3781.             return decodedname;
  3782.     
  3783.         },
  3784.         
  3785.         getMainPersonaDirectoryFileURL:function() {
  3786.                         
  3787.             var file = Components.classes["@mozilla.org/file/directory_service;1"]
  3788.                                  .getService(Components.interfaces.nsIProperties)
  3789.                                  .get("ProfD", Components.interfaces.nsIFile);
  3790.  
  3791.             file.append("personasrotator");
  3792.     
  3793.                         
  3794.             var ios = Components.classes["@mozilla.org/network/io-service;1"]
  3795.                                 .getService(Components.interfaces.nsIIOService);
  3796.             var URL = ios.newFileURI(file);
  3797.             
  3798.  
  3799.             return URL.spec;
  3800.         
  3801.         },
  3802.  
  3803.         windowOnClose:function(event){
  3804.         
  3805.             if(PersonasWindow.updateModeOn){
  3806.                 var answer=PersonasWindow.createConfirmPrompt(PersonasWindow.STRINGS.getString("onCloseWarning"));
  3807.             
  3808.                 if(!answer) {event.preventDefault();return;}
  3809.                 else{return}
  3810.                 
  3811.             }
  3812.             
  3813.         },
  3814.         
  3815.         bringCSS:function(event){
  3816.             
  3817.             //obsolete
  3818.             var styleNode=document.getElementById("dbutton");
  3819.             var styleObject=styleNode.style;
  3820.  
  3821.             var object=styleObject; 
  3822.  
  3823.             var objectHash="";
  3824.             var objectHash2="";
  3825.  
  3826.             var cssProperties=[];
  3827.             
  3828.             for (var property in object) {
  3829.  
  3830.                 cssProperties.push(property);
  3831.  
  3832.             }
  3833.  
  3834.             var trimmedCssProperties=[];
  3835.             var open=false;
  3836.             var secondopen=false;
  3837.  
  3838.             for (var i=0;i<cssProperties.length;i++) {
  3839.  
  3840.                 if(i>13||i==2||i==3||i==4) {
  3841.  
  3842.                     while(cssProperties[i].search(/[A-Z]/)+1){
  3843.                         
  3844.                         var foundCharacter=cssProperties[i].match(/[A-Z]/);
  3845.                         
  3846.                         var splitArray=cssProperties[i].split(foundCharacter.toString());
  3847.                         
  3848.                         var emptyString="";
  3849.  
  3850.                         for (var o=0;o< splitArray.length;o++){
  3851.                         
  3852.                             if(o< splitArray.length-1) emptyString+=splitArray[o]+"-"+(foundCharacter.toString().toLowerCase());
  3853.                             else {emptyString+=splitArray[o]}
  3854.  
  3855.                         }
  3856.  
  3857.                         cssProperties[i]=emptyString;
  3858.                     
  3859.                     }
  3860.  
  3861.                     trimmedCssProperties.push(cssProperties[i]);    
  3862.                 
  3863.                 }
  3864.  
  3865.             }
  3866.  
  3867.             for (var i=0;i<trimmedCssProperties.length;i++) {
  3868.                 
  3869.                 var node=styleNode;
  3870.             
  3871.                 var cssValue=document.defaultView.getComputedStyle(node, null).getPropertyValue(trimmedCssProperties[i]);
  3872.                 
  3873.                 if(cssValue!="") objectHash+="<strong>"+trimmedCssProperties[i]+"</strong>"+":"+cssValue+";<br/>";
  3874.             
  3875.             }
  3876.  
  3877.             function createLogDiv(type,passedLog){
  3878.  
  3879.     var log=passedLog;
  3880.  
  3881.     var doc=window.opener.content.document;
  3882.     var logdiv = doc.createElement("div");
  3883.     var closediv = doc.createElement("div");
  3884.     var wrapperdiv = doc.createElement("div");
  3885.  
  3886.     closediv.style.textAlign = "center";
  3887.     closediv.innerHTML="<a onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);event.preventDefault();' style='background-color:red;color:white;'>CLOSE (X)</a>";
  3888.  
  3889.     logdiv.style.width="900px";
  3890.     logdiv.style.height="480px";
  3891.     logdiv.style.overflow="auto";
  3892.     
  3893.     if (type=="html") logdiv.innerHTML=log;
  3894.     else {
  3895.         var textarea=doc.createElement("textarea");
  3896.         textarea.value=log;
  3897.         textarea.style.width="896px";
  3898.         textarea.style.height="473px";
  3899.         textarea.style.overflow="auto";
  3900.         logdiv.appendChild(textarea);
  3901.     }
  3902.  
  3903.     wrapperdiv.style.position="absolute";
  3904.     wrapperdiv.style.width="900px";
  3905.     wrapperdiv.style.height="500px";
  3906.     wrapperdiv.style.top="0";
  3907.     wrapperdiv.style.left="0";
  3908.     wrapperdiv.style.backgroundColor="#FFFFFF";
  3909.     wrapperdiv.style.color="#000000";
  3910.     wrapperdiv.style.border="2px solid #000000";
  3911.  
  3912.     wrapperdiv.appendChild(closediv);
  3913.     wrapperdiv.appendChild(logdiv);
  3914.  
  3915.     doc.body.appendChild(wrapperdiv);
  3916.  
  3917. }
  3918.  
  3919.  
  3920.  
  3921. //pass appropritate log. type can either be "html" or "text".
  3922. createLogDiv("html",objectHash);
  3923.                 
  3924.         },
  3925.             
  3926.         handledonateclick:function(){
  3927.         
  3928.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  3929.         
  3930.             
  3931.             var visibleInfoDivs=document.getElementsByClassName("infovisible");
  3932.                 
  3933.             for (var i=0;i<visibleInfoDivs.length;i++) {
  3934.                 
  3935.                 PersonasWindow.removeClass(visibleInfoDivs[i],"infovisible");
  3936.                 
  3937.             }    
  3938.         
  3939.             if(PersonasWindow.editstate==true) {
  3940.             
  3941.                 var edithtmldiv=document.getElementsByClassName("edithtmldiv")[0];
  3942.                 
  3943.                 edithtmldiv.parentNode.removeChild(edithtmldiv);
  3944.                 
  3945.                 PersonasWindow.editstate=false;
  3946.                 
  3947.             }            
  3948.         
  3949.             if(!PersonasWindow.hasClass(document.getElementById("newsheading"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("newsheading"),"buttoninactive");}
  3950.             
  3951.             if(!PersonasWindow.hasClass(document.getElementById("gallerynavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("gallerynavbuttons"),"buttoninactive");}
  3952.             
  3953.             if(!PersonasWindow.hasClass(document.getElementById("editnavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("editnavbuttons"),"buttoninactive");}
  3954.  
  3955.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  3956.             
  3957.             if(document.getElementsByClassName("active")[0]!=undefined)  PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  3958.             
  3959.             if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined)  PersonasWindow.removeClass(document.getElementsByClassName("activecollectionbutton")[0],"activecollectionbutton");
  3960.  
  3961.             PersonasWindow.addClass(document.getElementById("donatediv"),"active");
  3962.             
  3963.             PersonasWindow.removeClass(document.getElementById("donatediv"),"inactive");
  3964.         
  3965.         },
  3966.         
  3967.         opentutorialpage:function(node){
  3968.         
  3969.             node=node.parentNode;
  3970.             var openurl="";
  3971.         
  3972.             if(node.getAttribute("id")=="viewwalltut"){openurl="http://personasrotator.com/wrext_viewwalltutorial.php"}
  3973.             else if(node.getAttribute("id")=="addnewwalltut"){openurl="http://personasrotator.com/wrext_addnewwalltutorial.php"}
  3974.             else if(node.getAttribute("id")=="installnewwalltut"){openurl="http://personasrotator.com/wrext_installnewwalltutorial.php"}
  3975.             else if(node.getAttribute("id")=="wallposchangetut"){openurl="http://personasrotator.com/wrext_wallposchangetutorial.php"}
  3976.             else if(node.getAttribute("id")=="browseinstwalltut"){openurl="http://personasrotator.com/wrext_browseinstwalltutorial.php"}
  3977.             else if(node.getAttribute("id")=="browsecomsitetut"){openurl="http://personasrotator.com/wrext_browsecomsitetutorial.php"}
  3978.             else if(node.getAttribute("id")=="uploadwalltut"){openurl="http://personasrotator.com/wrext_uploadwalltutorial.php"}
  3979.             else if(node.getAttribute("id")=="addnewcoltut"){openurl="http://personasrotator.com/wrext_addnewcoltutorial.php"}
  3980.             else if(node.getAttribute("id")=="getfurtherhelptut"){openurl="http://personasrotator.com/wrext_getfurtherhelptutorial.php"}        
  3981.             
  3982.             if (window.opener!=undefined && window.opener.gBrowser!=undefined){
  3983.             
  3984.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab(openurl);
  3985.                 window.opener.focus();
  3986.             
  3987.             }
  3988.         
  3989.         },
  3990.         
  3991.         handlehelpclick:function(){
  3992.         
  3993.             if(PersonasWindow.updateModeOn==true) {PersonasWindow.createAlertPrompt(PersonasWindow.retrieveAppropriateAlertText());return;};
  3994.             
  3995.             var visibleInfoDivs=document.getElementsByClassName("infovisible");
  3996.                 
  3997.             for (var i=0;i<visibleInfoDivs.length;i++) {
  3998.                 
  3999.                 PersonasWindow.removeClass(visibleInfoDivs[i],"infovisible");
  4000.                 
  4001.             }    
  4002.             
  4003.             if(PersonasWindow.editstate==true) {
  4004.             
  4005.                 var edithtmldiv=document.getElementsByClassName("edithtmldiv")[0];
  4006.                 
  4007.                 edithtmldiv.parentNode.removeChild(edithtmldiv);
  4008.                 
  4009.                 PersonasWindow.editstate=false;
  4010.                 
  4011.             }            
  4012.         
  4013.             if(!PersonasWindow.hasClass(document.getElementById("newsheading"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("newsheading"),"buttoninactive");}
  4014.             
  4015.             if(!PersonasWindow.hasClass(document.getElementById("gallerynavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("gallerynavbuttons"),"buttoninactive");}
  4016.             
  4017.             if(!PersonasWindow.hasClass(document.getElementById("editnavbuttons"),"buttoninactive")) {PersonasWindow.addClass(document.getElementById("editnavbuttons"),"buttoninactive");}
  4018.  
  4019.             if(document.getElementsByClassName("active")[0]!=undefined) PersonasWindow.addClass(document.getElementsByClassName("active")[0],"inactive");
  4020.             
  4021.             if(document.getElementsByClassName("active")[0]!=undefined)  PersonasWindow.removeClass(document.getElementsByClassName("active")[0],"active");
  4022.             
  4023.             if(document.getElementsByClassName("activecollectionbutton")[0]!=undefined)  PersonasWindow.removeClass(document.getElementsByClassName("activecollectionbutton")[0],"activecollectionbutton");
  4024.  
  4025.             PersonasWindow.addClass(document.getElementById("helpdiv"),"active");
  4026.             
  4027.             PersonasWindow.removeClass(document.getElementById("helpdiv"),"inactive");
  4028.         
  4029.         },
  4030.  
  4031.         visitDonationPage:function(){
  4032.         
  4033.             if (window.opener!=undefined && window.opener.gBrowser!=undefined){
  4034.             
  4035.                 window.opener.gBrowser.selectedTab = window.opener.gBrowser.addTab('http://personasrotator.com/wrext_donate.php?ext');
  4036.                 window.opener.focus();
  4037.             
  4038.             }
  4039.             
  4040.             
  4041.         },
  4042.             
  4043.     }
  4044.         
  4045.         
  4046.     window.addEventListener("click",PersonasWindow.retrieveclicknode,true);
  4047.     window.addEventListener("load",PersonasWindow.handleWindowLoad,false);
  4048.     window.addEventListener("close",PersonasWindow.windowOnClose,false);
  4049.